2011-05-26 53 views
1
ProductCollection select = new 
     Select(Product.SupplierIDColumn).From<Product>().Distinct() 
     .ExecuteAsCollection<ProductCollection>(); 

http://subsonicproject.com/docs/Distinct问题亚音速3

从例子中,我想从我的表,但是许多问题得到不同的类别上面DISTINCT查询来

  1. 我不能把列这样Product.SupplierIDColumn我不知道为什么我的班级EventListing没有这些列的intellisense
  2. Distinct()功能不可用后From<EventListing>()

回答

0

有趣的是,它看起来像SubSonic 2中的SqlQuery类有一个Distinct()方法,但SubSonic 3中的SqlQuery类没有。你可以尝试SS2而不是3,或者如果你使用3,我建议使用Linq表达式。换句话说,这样的:

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

- 或 -

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