Web application use to manage pies.
As a owner of pie shop I want to manage a pies, categories (of pies) and orders.
Web application use to manage pies
Project architecture:
MVC architecture with extension using repository pattern
Operations on pie's and categories (look interfaces IPieRepository and ICategoryRepository).
Track changes: This is one of the main function on Entity framework.
EF track changes on rows (add, modify, delete)
Changes are related to existing object DbContext
var entries = context.ChangeTracker.Entries();
foreach (var entry in entries) { Console.WriteLine("Entity Name: {0}", entry.Entity.GetType().Name); Console.WriteLine("Status: {0}", entry.State); }
Entity Name: Student Status: Unchanged
Entity Name: Enrollment Status: Added
When we only load data to see on page (Categories to dropdown) then we could use AsNoTracking() method
IEnumerable employeeIEnumberable = db.Employee.Where(a =>; a.JobTitle.StartsWith("P")); employeeIEnumberable = employeeIEnumberable.Take(5)
Looks in sql: select * from HumanResources.Employee where JobTitle like 'P%'
IQueryable employeeIQueryable = db.Employee.Where(a => a.JobTitle.StartsWith("P")); employeeIQueryable = employeeIQueryable.Take(5)
Looks in sql: select top(5) * from HumanResources.Employee where JobTitle like 'P%'
IQueryable is optymalization on database side
Using IMemoryCache - stores data in memory server
Set and use cache basicly on get data (load data to memory)
Remove cache on add, update, delete data