ADO.Net DataService 性能问题
我们正在使用 ADO.Net DataService(.Net Framework 4.0、Visual Studio 2010)。我们有选择、插入、更新和删除操作。
- 对于选择,我们有像
School school = _context.School.Expand("Address, ContactPerson, ContactPerson/Details......").Where(S => S.Name == "xxx").SingleOrDefault( );
用于插入
_context.AddToSchool(学校); _contextSaveChanges();
地址.学校代码 = 学校.代码; //// 地址与学校有关系
_context.AddToAddress(address);
//现在我们没有任何级联插入操作。
对于更新,我们使用这样的
//每次更新时,我们在创建对象时,都会面临“上下文已跟踪实体”或“上下文未跟踪”等问题。这是最糟糕的做法:(
_context = new DataContext(......)
AttachObject("学校", 学校); _context.UpdateObject(学校); _context.SaveChanges();
用于在更新时附加对象的代码片段。
private void AttachObject(字符串实体集名称,对象实体) {
if (!_container.Entities.Where(entities =>Entity.Entity==entity).Any()) { _container.AttachTo(entitySetName, 实体); }
}
用于删除
//现在我们还没有任何级联删除操作。
地址地址 = _context.Address.where(A => A.Code == deleteAddress.Code).SingleOrDefault();
_context.DeleteObject(地址); _context.SaveChanges();
即使在本地系统中,这也需要大量时间。我害怕性能,这需要在单独的服务器中启动。请告诉我使用“ADO.Net DATASERVICE”的最佳方法是什么,
我需要答案而不是否决票:)
编辑< /strong> :我检查了 5 行、10 列和 4 个嵌套表的范围。即使我可以看到单行更新的 UI 冻结 5 秒。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还不会排除这个询问。
现在查询
希望有所帮助。
I wouldn't rule out the query just yet.
Now the query
Hope that helps.