LINQ到查询对象当SQL +计算器异常 [英] linq to sql + stackoverflow exception when querying objects

查看:121
本文介绍了LINQ到查询对象当SQL +计算器异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,我已经证实了我只有这个问题时,我试图在主键查询,如果在实体主键被设置为自动生成的值' - 但W / O型,我怎么可以插入?很抱歉,如果这是一个小白LINQ2SQL,但我刚开始使用它。

OK, i have confirmed i only this issue when i attempt to query on the primary key if that primary key in the entity is set to 'Auto Generated Value' -- but w/o this, how can i insert? Sorry if this is a noob linq2sql but i just started working with it.

一个人如何去使用LINQ to SQL中使用此选项关闭,但也有DB处理PK的?我不想有QRY每次得到的PK,我应该分配...

How does one go about using Linq to Sql with this option turned off but also have the db handle the pk's? I would hate to have to qry everytime to get the pk i should assign...

我希望有人能帮助我,即时通讯完全无法使用LINQ在我的项目,真的不知道该怎么办......这里就是一个例子,这条线将引发计算器例外。

I hope someone can help me out, im completely unable to use linq to sql in one of my projects, not really sure what to do... here is an example, this line throws a StackOverflow exception.

MyDataContext dc = new MyDataContext(ConnStr);
var obj = dc.MyDataTable.AsQueryable().SingleOrDefault(a => a.pkID == 4);

- 这第二行抛出的StackOverflow异常

-- That second line throws the StackOverflow exception.

继承人使用相同的DataContext另一个例子

Heres another example using the same datacontext

var o = dc.MyDataTable.Take(1); <-- works fine
var abc = o.ToArray();  <-- unable to evaluate, debugger stops

任何想法,我能试试吗?我似乎使用LINQ在同一个解决方案的另一个项目为sql好起来的。

Any ideas what i can try? I seem to be fine using linq to sql in another project in the same solution.

- UPDATE-- 我忘了提,这个特殊的实体MyDataTable有PK设定为自动生成的值' - 我有它设置为这个原因我已经SQL做自动递增,这是标识列

-- UPDATE-- I forgot to mention that this particular entity 'MyDataTable' has the pk set as 'Auto Generated Value' -- i have it set to this cause i have sql doing auto increment and this is the identity column.

推荐答案

如何PKID实施?任何机会,这是递归的以某种方式?

How is pkID implemented? Any chance it's recursive in some way?

这篇关于LINQ到查询对象当SQL +计算器异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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