I\'m currently planning on switching my \"manual query-writing\" code to a nice SQL framework, so I can leave the queries or sql things to the framework, instead of writing
You can use Single
or First
methods.
The difference between those methods is that Single expects a single row and throws an exception if it doesn't have a single row.
The usage is the same for both of them
(Based on VS 2015) If you create an .edmx (Add --> ADO.NET Entity Data Model).
Go through the steps to created the ".edmx" and use the following to run the stored procedure. emailAddress
is the parameter you are passing to the stored procedure g_getLoginStatus
. This will pull the first row into LoginStatus
and status
is a column in the database:
bool verasity = false;
DBNameEntities db = new DBNameEntities(); // Use name of your DBEntities
var LoginStatus = db.g_getLoginStatus(emailAddress).FirstOrDefault();
if ((LoginStatus != null) && (LoginStatus.status == 1))
{
verasity = true;
}
var address = Context.Addresses.First(a => a.Id == addressId);