I can get the identity of the currently logged in SQL Server user by using the SYSTEM_USER value, but is there a way to do this via linq somehow? I’m looking for something like the below:
var query = from u in dataContext.Users
where u.domainname == dataContext.system_user
select u.fullname;
Using something like Environment.UserName won’t work in the event a non-domain user authenticates via VPN, and querying via a separate statement is undesirable because I’d like to use just one statement to get the data.
Calling system functions can be done by creating new functions in the database which can be mapped further in the ORMs. It depends then on the ORM capabilities regarding to mapping user database functions.
LINQ2SQL and EF will create a single SQL statement for the following LINQ query.