I am wondering since nhibernate has to make the entire object does it make sense to do this?
Session.Query<Table>().Where(x => x.Id == id).Select(x => x.ColumnA).FirstOrDefault();
or would it be better to do this
Session.Query<Table>().Where(x => x.Id == id).FirstOrDefault();
I am trying to decide if I should make a separate method in my service layer to just return back ColumnA and have another method that returns all the fields back.
Or should I just have the one method that return all the fields like the second example would.
On one hand if I do it the first way then less data has to come back from the database especially when you know only one column will be used. On the other hand though it would suck if I need to it for each column.
Session.Query<Table>().Where(x => x.Id == id).Select(x => x.ColumnB).FirstOrDefault();
Session.Query<Table>().Where(x => x.Id == id).Select(x => x.ColumnC).FirstOrDefault();