Question

Currently when using OrmLite library from ServiceStack if I want single entity selected I do:

AppUser user = db.First<AppUser>(q => q.Id == id);

However since Single is more precise (obviously I want exception thrown if somehow multiple users with same id ended up in database) I was wondering if there is overload that I can use. Currently when I do db.Single I just get that overload with manual filtering:

public static T SingleOrDefault<T>(this IDbConnection dbConn, string filter);
Was it helpful?

Solution

OK, I found what the issue is - the version I'm using (3.9.71) doesn't have that overload - it was added later:

https://github.com/ServiceStack/ServiceStack.OrmLite/commit/f2f5f80f150f27266bdcaf81b77ca60b62897719#diff-e9a84724e6a8315ec7f7fc5a5512a44b

Seems I'll need to extend that class from within my code.

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