I started by writing code like so:
users.FindOneAs<User>(Query.EQ("username", Username));
but I was unhappy about having strings in the code for types which are known, so I moved to:
users.FindOneAs<User>(Query.EQ(Check(() => User.T.username ),
Username ));
by adding the following:
in User class:
public static readonly User T = null;
locally:
private static string Check<T>(Expression<Func<T>> expr)
{
var body = ((MemberExpression)expr.Body);
}
Now we have static checking, but a little more code. Is there a better way to do this using the driver without Linq?
Thanks