开发者

How to group with a written specified DataContextClass?

开发者 https://www.devze.com 2023-02-22 02:17 出处:网络
I want to group dvdlist by categoryid, Similar to this, but no DVDDataContext This one works, DvdDataContext db = new DvdDataContext();

I want to group dvdlist by categoryid, Similar to this, but no DVDDataContext This one works,

DvdDataContext db = new DvdDataContext();
var q = from b in db.DvdLists
        group b by b.CategoryId into g
        select new { CategoryID = g.Key, DvdLists = g };
开发者_如何学运维

I need the following kind of code, but the error occurs at GetTable()=g

DataContext db = new DataContext(conString);
var dvd = db.GetTable<DvdList>();
var query = from b in dvd
            group b by b.CategoryId into g
            select new { CategoryId = g.Key, GetTable<DvdList>()= g }; 


You cannot specify GetTable() in anonymous types. Try { CategoryId = g.Key, GetTable= g };

Hope it helps!

0

精彩评论

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