开发者

How to group with a written specified DataContextClass?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜