Question

Can I return it as an object if I am doing a

Select OneItem from Table Where OtherItem = "blah"?

Is there a better way to do this?

I am building a constructor to return an object based on its name rather than its ID.

Was it helpful?

Solution

query.UniqueResult<T>() returns just one T

OTHER TIPS

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top