LINQ更新查询生成,其中0 = 1? [英] Linq Update Query generates Where 0 = 1?

查看:238
本文介绍了LINQ更新查询生成,其中0 = 1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置通过LINQ的2条SQL生成的类的地址,当我尝试的SubmitChanges(),它生成的SQL查询是:

I am setting the Address of a class generated by Linq 2 Sql and when I try to SubmitChanges(), the sql query it generates is:

Update Users
Set Address = @po
Where 0 = 1
--@po: Input VarChar (Size = 15; Prec = 0; Scale = 0) [123 45th Street]

我想不通为什么我收到其中0 = 1。

I can't figure out why I am getting Where 0 = 1.

推荐答案

在你的对象模型从数据库中的不同,这可能发生,甚至一个属性

This can happen when your object model differs from the database even by one property.

有没有可能是地址在数据库中,而不是在你的模型为空的,或其他方式?或类型不同,说NTEXT VS nvarchar的,等等?在某些情况下,它可以是另外一个不相关的财产......回想起过去的变化来所做的数据库或模式,确保这就是同步。

Is it possible that Address is nullable in the database and not in your model, or the other way around? Or the type differs, say ntext vs nvarchar, etc? In some cases it can be another unrelated property...think back to the last change to the database or model you made, make sure that's in sync.

这篇关于LINQ更新查询生成,其中0 = 1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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