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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -