I am new to SubSonic and Linq Stuff and I am trying a figure out the shortest and optimal way of retrieving a single record.
What other way is quicker and requires less code to write than this to get a single record?
User user2 = DB.Select().From(User.Schema)
.Where(User.PasswordColumn).IsEqualTo(password)
.And(User.SINumberColumn).IsEqualTo(siNumber)
.ExecuteSingle<User>();
I have used to AntsProfiler tool to check, and this takes avg of 29.12ms CPU time - tested over ten runs
Where as this takes even longer
UserController uc = new UserController();
Query query = new Query("User");
query.WHERE(User.Columns.Password, password);
query.WHERE(User.Columns.SINumber, siNumber);
User user = uc.FetchByQuery(query).First<User>();
Just the last line take 256.08ms CPU time plus UserController takes 66.86ms.
Any suggestions?