外键导致WCF套接字连接中止 [英] Foreign Key Causes WCF Socket Connection to Abort

查看:58
本文介绍了外键导致WCF套接字连接中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表,即Unit和SubUnit,它们之间存在一对多的关系:一个Unit可以有0个或多个SubUnit.

I have 2 tables, Unit and SubUnit, with a one to many relationship: a Unit can have 0 or more SubUnits.

我在WCF Windows服务中使用Linq to SQL(.dbml文件)来访问数据库.

I use Linq to SQL (.dbml files) in a WCF Windows Service to access the database.

使用服务客户端,我可以调用任何方法来检索单元或子单元,并且只要数据库中没有子单元(SubUnit表中的0行),它就可以正常工作.

Using the Service Client, I call any method to retrieve either the Units or the SubUnits and it works fine...as long as there are no SubUnits in the database (0 rows in the SubUnit table).

如果有1个或多个SubUnit,则在调用相同的方法时出现以下错误:

If there is 1 or more SubUnits, I get the following errors when calling the same methods:

  • 套接字连接已中止..."
  • 具有内部异常读取操作失败,请参阅内部例外."
  • 内部异常套接字连接为流产了..."
  • 内部有异常"现有连接被强行由远程主机关闭"

我删除了这些表并重新创建了它们,我将 Unit/SubUnit 表重新添加到 DBML,重新安装了服务等.我以前从未遇到过这个问题.

I've dropped the tables and re-created them, I've re-added the Unit/SubUnit tables to the DBML, re-installed the service, etc. I've never run into this problem before.

我知道尝试通过WCF传递过多数据可能会导致套接字异常中止"错误,但是数据库中当前有1个单元和1个子单元,我仍然会收到此错误!

I understand the "Socket aborted" error can be caused by trying to pass too much data over WCF, but there is currently 1 Unit with 1 SubUnit in the database and I still get this error!

任何人都可以对此有所了解吗?

Can anyone shed some light on this?

推荐答案

您需要添加[DataContract(IsReference = true)] attr.到您的实体.

You need to add [DataContract(IsReference = true)] attr. to your entity.

这篇关于外键导致WCF套接字连接中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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