Text after "
I am using business to read the values in an object created by me where I have a basic stored procedure
if selected (select UT.UserID = @UserId from UT.UserID) UserTable UTs Select UT.UserID, UT.Name, UT.Surname, UT .TrackingString Start UserTable UTs where UT.UserID = @UserId END
and this is the code in my visual model.
IDbConnection Connection; (Connection = New SqlConnection ("ConfigurationManager.ConnectionStrings [" Liberty "] ToString ()).) {Var results = connection.QueryMultiple (" GetUserData ", new {UserId = userId.ToLower ()}, commandType: CommandType .StoredProcedure); User = results Read & lt; UserData & gt; (). first (); }
How does, then the column was selected. I can check in the result. This moment I get an InvalidOperation exception if there is no user data to get there (if user does not exist Is) as it is on.
Use the right Linq method as an invalid result that you are using a If you do not have any results, while none of your users are present, then your query can return any value
Switch to a method that does not throw away any elements on the calculation, then the null Check for it and handle it gracefully.
// erosion user = results. Read & LT; UserData & gt; () FirstOrDefault (); } If (user == tap) {// If no such user exists, then do something about it
No comments:
Post a Comment