views:

1107

answers:

3

Can I return it as an object if I'm doing a Select OneItem from Table Where OtherItem = "blah"?

Is there a better way to do this?

I'm building a constructor to return an object based on its name rather than its ID

+3  A: 

query.UniqueResult() returns just one T

Ben Scheirman
+1  A: 

If there's more than one potential result, then query.FirstResult() might be better.

David Kemp
A: 

Or using LINQ you can have query.First(), query.SingleOrDefault(), query.Min(predicate) etc...

ip