ADO.Net DataService 性能问题

发布于 2024-09-24 13:57:00 字数 1432 浏览 1 评论 0原文

我们正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁梦 2024-10-01 13:57:00

我还不会排除这个询问。

  1. 数据大小是多少?几百行、几百万行还是几亿行?
  2. 索引和磁盘性能?
  3. 如果是远程服务器,连接如何?

现在查询

  1. 确保您没有扩展重复数据。仅扩展需要的内容。
  2. 检查您正在扩展的其他数据类型,可能是图像的二进制数据等。

希望有所帮助。

I wouldn't rule out the query just yet.

  1. What's the data size? A few hundred rows, a few million, or a few hundred million?
  2. Index and Disk performance?
  3. If it's a remote server, how's the connection?

Now the query

  1. Make sure you are not expanding duplicate data. Expand only what's needed.
  2. Check for other data types you are expanding, perhaps binary for Images etc.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文