开发者

Using Linq on a Dataset

开发者 https://www.devze.com 2022-12-30 22:16 出处:网络
Can someone enlighthen me with regards to Linq please? I have a dataset that is populated via a SQL Stored Procedure, the format of which is below:

Can someone enlighthen me with regards to Linq please?

I have a dataset that is populated via a SQL Stored Procedure, the format of which is below:

Country | Brand | Variant | 2004 | 2005 | 2006 | 2007 | 2008

The number of rows varies between 50 and several thousand.

What I'm trying to do is use Linq to interrogate the dataset (there will be several Linq queries based on user options), but a simple example would be to SUM the year columns based on Brand.

I have the following that I believe creates a template for me to work with:

But from here on I'm absolutely stuck!

                sqlDA.Fill(ds, "Profiler")

            Dim brandsQuery = From cust In ds.Tables(0).AsEnumerable()
                              Select _BrandName = cust.Item("BrandNam开发者_高级运维e"),
                              _y0 = cust.Item("1999"),
                              _y1 = cust.Item("2004"),
                              _y2 = cust.Item("2005"),
                              _y3 = cust.Item("2006"),
                              _y4 = cust.Item("2007"),
                              _y5 = cust.Item("2008")

I'm tried to look at examples, but can't see any that are VB.Net based and/or show me how to Sum/Group.

Can someone please provide an example so I can perhaps learn from it.

Thanks.


You might want to look at http://msdn.microsoft.com/en-us/vbasic/bb738016.aspx for your specific grouping / sum abitilities and http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx for LINQ to Dataset in general.

0

精彩评论

暂无评论...
验证码 换一张
取 消