LinqToSql和WCF [英] LinqToSql and WCF

查看:64
本文介绍了LinqToSql和WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个使用WCF服务与数据库进行交互的n层应用程序中,在整个应用程序中使用LinqToSql类的最佳实践方法是什么?

我已经看到它做了几种不同的方式,但是它们似乎花了很多时间来创建额外的接口,消息类等,从而减少了不必编写数据访问代码所带来的好处.

目前是否有很好的方法?我们是否还在等待实体框架?

解决方案

LINQ to SQL并不真正适合与分布式应用程序一起使用.更改跟踪和延迟加载是与数据库关联的DataContext的一部分,因此无法跨线传输.您可以跨线移动L2S实体,对其进行修改,将它们移回并通过将它们重新连接到DataContext来更新数据库,但这非常有限,并且由于旧值永远都不会保留,因此您将丢失所有并发检查.

顺便说一句,我相信L2E也是如此.

Within an n-tier app that makes use of a WCF service to interact with the database, what is the best practice way of making use of LinqToSql classes throughout the app?

I've seen it done a couple of different ways but they seemed like they burned a lot of hours creating extra interfaces, message classes, and the like which reduces the benefit you get from not having to write your data access code.

Is there a good way to do it currently? Are we stuck waiting for the Entity Framework?

解决方案

LINQ to SQL isn't really suitable for use with a distributed app. The change tracking and lazy loading is part of the DataContext which is tied to the database so cannot travel across the wire. You can move L2S entities across the wire, modify them, move them back and update the database by reattaching them to the DataContext but that is pretty limited and you lose all concurrency checks as the old values are never kept around.

BTW I believe the same is true for L2E.

这篇关于LinqToSql和WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆