1

I have some code that calls GetSQLUser(defined in the code below)... If I put a breakpoint on var result, the result is not as I expected (a SqlUserInfo object... would be nice).

public class Whatever
{
    public void GetSQLUser()
    {
        var result = this.context.Database.SqlQuery<SQLUserInfo>("SELECT SYSTEM_USER AS UserID");
    }
}

public class SQLUserInfo
{
    string UserID { get; set; }
}

enter image description here

What am I doing wrong?

1 Answer 1

1

Try changing:

var result = this.context.Database.SqlQuery<SQLUserInfo>("SELECT SYSTEM_USER AS UserID");

to

var result = this.context.Database.SqlQuery<SQLUserInfo>("SELECT SYSTEM_USER AS UserID").First();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.