开发者

problem with Distinct query in subsonic 3

开发者 https://www.devze.com 2023-03-08 20:23 出处:网络
ProductCollection select = new Select(Product.SupplierIDColumn).From<Product>().Distinct() .ExecuteAsCollection<Pro开发者_开发技巧ductCollection>();
ProductCollection select = new 
        Select(Product.SupplierIDColumn).From<Product>().Distinct()
        .ExecuteAsCollection<Pro开发者_开发技巧ductCollection>();

http://subsonicproject.com/docs/Distinct

From above example I am trying to get distinct category from my table but many problems comes

  1. I can not put column like this Product.SupplierIDColumn I dont know why my class EventListing has no intellisense for these columns
  2. Distinct() function is not available after From<EventListing>().


Interestingly, it looks like the SqlQuery class in SubSonic 2 had a Distinct() method, but the SqlQuery class in SubSonic 3 does not. You could try SS2 instead of 3, or if you are using 3, I suggest using Linq expressions instead. In other words, something like:

var data = (from x in db.Products
            select x.SupplierId)
           .Distinct();

-or-

var data = db.Products.Select(x => x.SupplierId).Distinct();
0

精彩评论

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