Change your code into below format.
var hSdata_SData = default(DTO_HSData_SData);
if (id == null)
{
id = Convert.ToInt32(Session["HSApproveSId"]);
}
else
{
using (var db = new SupplierContext())
{
var dbhSdata_SData = (from sa in db.SApproval.AsQueryable()
join s in db.Suppliers.AsQueryable() on sa.SupplierId equals s.ID
join l in db.Users.AsQueryable() on sa.HUserId equals l.UserId
where sa.Sid == id
select new
{
CName = s.CName,
MContact = s.MContact,
HSUserName = l.FirstName,
HSStatus = sa.HSStatus,
HSNotes= sa.HSNotes,
HSDate= sa.HSDate
}).FirstOrDefault();
if (!ReferenceEquals(dbhSdata_SData , null))
{
hSdata_SData = new DTO_HSData_SData
{
CName = dbhSdata_SData .CName ,
MContact = dbhSdata_SData .MContact ,
HSUserName= dbhSdata_SData .HSUserName,
HSStatus= dbhSdata_SData .HSStatus,
HSNotes= dbhSdata_SData .HSNotes,
HSDate= dbhSdata_SData .HSDate
};
}
return View(hSdata_SData );
}
}
return View();
var hSdata_SData = default(DTO_HSData_SData);
if (id == null)
{
id = Convert.ToInt32(Session["HSApproveSId"]);
}
else
{
using (var db = new SupplierContext())
{
var dbhSdata_SData = (from sa in db.SApproval.AsQueryable()
join s in db.Suppliers.AsQueryable() on sa.SupplierId equals s.ID
join l in db.Users.AsQueryable() on sa.HUserId equals l.UserId
where sa.Sid == id
select new
{
CName = s.CName,
MContact = s.MContact,
HSUserName = l.FirstName,
HSStatus = sa.HSStatus,
HSNotes= sa.HSNotes,
HSDate= sa.HSDate
}).FirstOrDefault();
if (!ReferenceEquals(dbhSdata_SData , null))
{
hSdata_SData = new DTO_HSData_SData
{
CName = dbhSdata_SData .CName ,
MContact = dbhSdata_SData .MContact ,
HSUserName= dbhSdata_SData .HSUserName,
HSStatus= dbhSdata_SData .HSStatus,
HSNotes= dbhSdata_SData .HSNotes,
HSDate= dbhSdata_SData .HSDate
};
}
return View(hSdata_SData );
}
}
return View();
No comments:
Post a Comment