当前位置: 首页>>代码示例>>C#>>正文


C# DataContext.AddTable方法代码示例

本文整理汇总了C#中DataContext.AddTable方法的典型用法代码示例。如果您正苦于以下问题:C# DataContext.AddTable方法的具体用法?C# DataContext.AddTable怎么用?C# DataContext.AddTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataContext的用法示例。


在下文中一共展示了DataContext.AddTable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test2

        public void Test2()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => {
                if (!(value is int))
                    return null;
                var v = (int)value;
                if (v > 0)
                    return new Styling.CellStyle
                    {
                        FontStyle = new Styling.FontStyle
                        {
                            FontColor = Styling.Color.FromHtml("#00FF00")
                        }
                    };
                return null;
            };

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);

            var html = HtmlReportWriter.RenderReport(rep, new DefaultHtmlReportTheme());
            Assert.IsTrue(html.Contains("style=\"color:"));
            Assert.IsTrue(html.Contains("#00FF00"));
        }
开发者ID:elea30,项目名称:codereports,代码行数:34,代码来源:ConditionalFormattingTest.cs

示例2: BiggestCountries

        public static Report BiggestCountries()
        {
            var dc = new DataContext();
            var data = new Dictionary<string, GdpItem>();
            var src = Pecunia.Services.GdpDataProvider.GetData();
            var lastYear = src.Max(a=>a.Year);
            foreach (var item in src)
            {
                GdpItem i;
                if (!data.TryGetValue(item.Country, out i))
                    data.Add(item.Country, i = new GdpItem { Country = item.Country });
                i.Process(lastYear, item);
            }

            var res = data.Values.ToArray();
            dc.AddTable("data", res);

            var table = TableGenerator.GetTable(typeof(GdpItem), "data");
            table.Columns.Last().SortIndex = 0;
            table.Columns.Last().SortDirection = SortDirection.Descending;
            for (var i = 0; i < 5; i++)
            {
                table.Columns[i + 2].HeaderText = (lastYear - 4 + i).ToString();
            }

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.Add(table);

            return Report.CreateReport(flow, dc);
        }
开发者ID:borisdj,项目名称:dextop-pecunia,代码行数:30,代码来源:GdpYearColumns.cs

示例3: Test2

        public void Test2()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Name="1", Value = 2, G="1" },
                new Item { Name="2", Value = 3, G="1" },
                new Item { Name="3", Value = 4, G="2" }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(1, cells[2][0].Value);

            //G2
            Assert.AreEqual(1, cells[2][0].Value);

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[2][2].Value);
        }
开发者ID:elea30,项目名称:codereports,代码行数:29,代码来源:CellDisplayModeTests.cs

示例4: Test1

        public void Test1()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "Col2").ConditionalFormatting = (value) => { return new Styling.CellStyle(); };

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Assert.IsNull(cells[0][0].CustomStyle);
            Assert.IsNotNull(cells[0][1].CustomStyle);
        }
开发者ID:elea30,项目名称:codereports,代码行数:17,代码来源:ConditionalFormattingTest.cs

示例5: GetData

        DataContext GetData()
        {
            var dc = new DataContext();
            List<Item> t = new List<Item>();
            var r = new Random();
            for (var i = 0; i < Filter.Count; i++)
                t.Add(new Item
                {
                    V1 = r.Next(),
                    V2 = r.Next(),
                    V3 = r.Next(),
                    V4 = r.Next(),
                    V5 = r.Next()
                });

            dc.AddTable("table", t);

            return dc;
        }
开发者ID:codaxy,项目名称:dextop-candies,代码行数:19,代码来源:Report1.cs

示例6: Generate

        public static Report Generate()
        {
            var dc = new DataContext();
            var data = from item in Pecunia.Services.GdpDataProvider.GetData()
                       select new Item
                       {
                           Country = item.Country,
                           GDP = item.GDP,
                           GdpGrowth = item.GDPGrowth,
                           Year = item.Year,
                           GniPerCapita = item.GniPerCapita
                       };
            dc.AddTable("data", data.ToArray());

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            var table = flow.AddTable<Item>("data");
            table.Columns.Single(a => a.DataField == "GdpGrowth").ConditionalFormatting = ConditionalFormatters.PercentChange;

            return Report.CreateReport(flow, dc);
        }
开发者ID:borisdj,项目名称:dextop-pecunia,代码行数:20,代码来源:GdpByCountry.cs

示例7: Test1

        public void Test1()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item { Col1="A", Col2 = 2 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            StringWriter sw = new StringWriter();
            TextReportWriter.WriteTo(rep, sw);

            var lines = sw.ToString().Split('\n').Select(a=>a.TrimEnd('\r')).ToArray();

            Assert.AreEqual(lines[1], "=========");
            Assert.AreEqual(lines[2], "Col1 Col2");
            Assert.AreEqual(lines[3], "---- ----");
            Assert.AreEqual(lines[4], "A       2");
            Assert.AreEqual(lines[5], "---------");
        }
开发者ID:elea30,项目名称:codereports,代码行数:22,代码来源:TextExporterTests.cs

示例8: TestFooters

        public void TestFooters()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item2 { Name="1", Value = 2, G="1", Weight = 3 },
                new Item2 { Name="2", Value = 3, G="1", Weight = 1 },
                new Item2 { Name="3", Value = 4, G="2", Weight = 4 }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item2>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //Footers
            Assert.AreEqual(9m/4, cells[2][2].Value);
            Assert.AreEqual(16m/4, cells[4][2].Value);
            Assert.AreEqual(25m/8, cells[5][2].Value);
        }
开发者ID:elea30,项目名称:codereports,代码行数:24,代码来源:WeightedAverageTest.cs

示例9: TwoLevelGrouping

        public void TwoLevelGrouping()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item {  Amount = 10, BrokerageHouseCode = "ADBR", Revoked = false },
                new Item {  Amount = 20, BrokerageHouseCode = "ADBR", Revoked = true},
                new Item {  Amount = 30, BrokerageHouseCode = "MOBR", Revoked = true },
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //False
            //=================================
            //ADBR
            //=================================
            //BrokerageHouseCode Revoked Amount
            //------------------ ------- ------
            //ADBR               False       10
            //---------------------------------
            //                               10
            //---------------------------------
            //                               10

            //True
            //=================================
            //ADBR
            //=================================
            //BrokerageHouseCode Revoked Amount
            //------------------ ------- ------
            //ADBR               True        20
            //---------------------------------
            //                               20

            //MOBR
            //=================================
            //BrokerageHouseCode Revoked Amount
            //------------------ ------- ------
            //MOBR               True        30
            //---------------------------------
            //                               30
            //---------------------------------
            //                               50

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));
            Assert.AreEqual(16, cells.Count);

            Assert.AreEqual("False", cells[0][0].Value);
            Assert.AreEqual("ADBR", cells[1][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[2][0].Value);
            Assert.AreEqual(10m, cells[3][2].Value);
            Assert.AreEqual(10m, cells[4][2].Value);
            Assert.AreEqual(10m, cells[5][2].Value);
            Assert.AreEqual("True", cells[6][0].Value);
            Assert.AreEqual("ADBR", cells[7][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[8][0].Value);
            Assert.AreEqual(20m, cells[9][2].Value);
            Assert.AreEqual(20m, cells[10][2].Value);
            Assert.AreEqual("MOBR", cells[11][0].Value);
            Assert.AreEqual("BrokerageHouseCode", cells[12][0].Value);
            Assert.AreEqual(30m, cells[13][2].Value);
            Assert.AreEqual(30m, cells[14][2].Value);
            Assert.AreEqual(50m, cells[15][2].Value);
        }
开发者ID:elea30,项目名称:codereports,代码行数:67,代码来源:GroupingTests.cs

示例10: TestFooters

        public void TestFooters()
        {
            var dc = new DataContext();
            dc.AddTable("data", new[] {
                new Item2 { Name="1", Value = 2, G="1" },
                new Item2 { Name="2", Value = 3, G="1" },
                new Item2 { Name="3", Value = 4, G="2" }
            });

            var flow = new Flow { Orientation = FlowOrientation.Vertical };
            flow.AddTable<Item2>("data");

            var rep = Report.CreateReport(flow, dc);
            var cells = ReportUtil.GetCellMatrix(rep);

            //Debug.WriteLine(ReportUtil.RenderTextReport(rep));

            Assert.AreEqual(6, cells.Count);

            //RowNumber
            Assert.AreEqual(1, cells[0][0].Value);
            Assert.AreEqual(2, cells[1][0].Value);
            Assert.AreEqual(1, cells[3][0].Value);

            //G2
            Assert.AreEqual(1, cells[3][0].Value);

            //Accumulator
            Assert.AreEqual(2, cells[0][2].Value);
            Assert.AreEqual(5, cells[1][2].Value);
            //G2
            Assert.AreEqual(4, cells[3][2].Value);

            //Footers
            Assert.AreEqual(5, cells[2][2].Value);
            Assert.AreEqual(4, cells[4][2].Value);
            Assert.AreEqual(9, cells[5][2].Value);
        }
开发者ID:elea30,项目名称:codereports,代码行数:38,代码来源:CellDisplayModeTests.cs


注:本文中的DataContext.AddTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。