Saturday, June 8, 2019
Friday, June 7, 2019
Thursday, June 6, 2019
Sunday, June 2, 2019
Linq Delete with EntityState
1.
public ActionResult Delete(int id)
{
using (var cont = new db_context())
{
var emp = new Employee()
{
emp_id = id
};
cont.Entry(emp).State = System.Data.Entity.EntityState.Deleted;
cont.SaveChanges();
}
return RedirectToAction("index");
}
public ActionResult Delete(int id)
{
using (var cont = new db_context())
{
var emp = new Employee()
{
emp_id = id
};
cont.Entry(emp).State = System.Data.Entity.EntityState.Deleted;
cont.SaveChanges();
}
return RedirectToAction("index");
}
LINQ Status with Any and condition in firstOrDefault
1. Status by Any
bool status = db.Employee.Any(x => x.emp_id == 1);
2. Condtion in FirstOrDefault
Employee employee = db.Employee.FirstOrDefault(x => x.emp_id == 1);
bool status = db.Employee.Any(x => x.emp_id == 1);
2. Condtion in FirstOrDefault
Employee employee = db.Employee.FirstOrDefault(x => x.emp_id == 1);
Subscribe to:
Posts (Atom)
Linq Expression syntax for where condtion in linq
(Expression<Func<T, bool>> filter)
-
Page preview on single click VS2015 or further or on single click page open in solution explorer Menu>Tools>Options>Environment...
-
(Expression<Func<T, bool>> filter)