I've just downloaded the Linq provider for NHibernate and am just a little excited. But I don't know Linq syntax that well.
I can return whole objects from a query like this:
var query = from foo in session.Linq<Kctc.BusinessLayer.Domain.Case>()
where foo.CaseNumber > 0
select foo;
And I can select a single property like this:
var query = from foo in session.Linq<Kctc.BusinessLayer.Domain.Case>()
where foo.CaseNumber > 0
select foo.Id;
But how would I select two properties, e.g. foo.Id and foo.Bar? Or is that not possible?
Thanks
David
Use an anonymous projection:
var query = from foo in session.Linq<Kctc.BusinessLayer.Domain.Case>()
where foo.CaseNumber > 0
select new { foo.Id, foo.Bar };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With