We are using ADO.Net DataService ( .Net Framework 4.0, Visual Studio 2010). We have Select, Insert, Update and Delete operations.
- For Selecting we have queries like
School school = _context.School.Expand("Address, ContactPerson, ContactPerson/Details......").Where(S => S.Name == "xxx").SingleOrDefault();
For Inserting
_context.AddToSchool(school); _contextSaveChanges();
address.SchoolCode = school.Code; //// Address have relation with school
_context.AddToAddress(address);
//Right now we don't have any Cascade Insert operation.
For update we are using like this
//Each time while updating, we are creating the object, We are facing the issues like "Context already tracking the entity" or "context is not tracked". This is worst Practice :(
_context = new DataContext(......)
AttachObject("Schools", school); _context.UpdateObject(school); _context.SaveChanges();
Code snippet which is used for Attach the object while updating.
private void AttachObject(string entitySetName, object entity) {
if (!_container.Entities.Where(entities => entities.Entity == entity).Any()) { _container.AttachTo(entitySetName, entity); }
}
For deleting
//Right now we don't have any cascade delete operation.
Address address = _context.Address.where(A => A.Code == deleteAddress.Code).SingleOrDefault();
_context.DeleteObject(address); _context.SaveChanges();
This is taking plenty of time even in local system. I'm scared of performance, this needs to be launched in separate server. Please tell me what is the best approach using "ADO.Net DATASERVICE"
I need the answer not Down Vote :)
EDIT : I checked with range of 5 Rows with column of 10, and nested table of 4. Even i can see UI freeze for single Row Update for 5 Seconds.