c# - Selecting only a few columns from a table -
i had problems using c#, nhibernate , link. in example bellow, select in brandtable, need "name" , "id" columns. select columns of table. using entityframework, same code bellow generates select 2 columns.
how in nhibernate?
using (isession session = myconnection.getcurrentsession()) { var brands = b in session.queryover<brandtable>().list() orderby b.name select new brand {id = b.id, name = b.name}; return brands.tolist(); }
you can't use query comprehensions queryover, because not linq provider. in example you're selecting records, , using linq objects. add nhibernate.linq namespace file , rewrite query
from b in session.query<brandtable>() orderby b.name select new brand {id = b.id, name = b.name};
Comments
Post a Comment