Fast insert
- _unitOfWorkRoute.Context.ChangeTracker.AutoDetectChangesEnabled = false;
- ef bulk insert.
- Install-Package Z.EntityFramework.Extensions
Like
_unitOfWorkVehicle.AmenityRepository.Table.Where(p => EF.Functions.Like(p.Name, "%arm%"));
Fast Update / Delete
- Bulk update
- update without select
using (var context = new StudentDbContext())
{
var student = new Student()
{
Id = 2,
Name = "Kasun"
};
context.Attach(student);
context.Entry(student).State = EntityState.Modified;
context.SaveChanges();
Console.WriteLine("saved");
}
var student = new Student()
{
Id = 2,
Name = "Kasun"
};
context.Attach(student);
context.Entry(student).Property(p => p.Name).IsModified = true;
context.SaveChanges();
No comments:
Post a Comment