I'm tring to get my product's types to a list with Linq.
var types = (from t in NHibernateSession.Linq<Product>()
select t.ProductType).Distinct().ToList<ProductType>();
return types;
But its giving an Unable to cast object of type error
'...Domain.Product' to type '...Domain.ProductType'.
ProductType is a property of Product.
<many-to-one name="ProductType" class="Portal.Domain.ProductType, TilePortal.Domain" column="ProductTypeID" not-null="true" ></many-to-one>
Edit: It seems like Linq to Nhibernate is not mature enough to handle such queries. I simply want to be able to create a simple SQL query that fetch distinct ProductType's from DB without bringing all products which is no-go for a production db that has millions of products. So if you can illustrate how to do this using HQL os Criteria API that will also do..