I found the solution, thanks to the magic of Extension methods. (They kick ass!) I decided to move my TableAdapter methods as extension methods of the IQueryable<_Entity_> class. So now for example, my User methods are inside their own class and they take this IQueryable<User> as the first parameter, like this:
public static User GetByEmail(this IQueryable<User> users, string email)
{
return users.SingleOrDefault(u => u.Email.ToLower() == email.ToLower());
}
This allows me to then say in my Business code:
var user = dataContext.Users.GetByEmail(email);
It's cool stuff because extension methods basically allowed me to modify the Users property of the DataContext from the outside, and keep all the user-related data-access logic neatly organized like it was before inside the TableAdapter. Cheers! Al
- Is God willing to prevent evil, but not able? Then he is impotent. - Is he able, but not willing? Then he is malevolent. - Is he both able and willing? Whence then is evil? - Is he neither able nor willing? Then why call him God? Epicurus