gpt4 book ai didi

c# - 在命令文本中使用 "not in"时出错

转载 作者:行者123 更新时间:2023-11-30 12:36:07 24 4
gpt4 key购买 nike

我有一个 EntityDataSource,其中不包含命令文本。

查询看起来像:-

SELECT  User.LastName,  User.Suffix  
FROM [User]
WHERE [User].UserId not in (select [Contractors].UserId from Contractors)

这会导致以下错误:-

The element type 'Edm.Guid' and the CollectionType 'Transient.collection[Transient.rowtype[(UserId ,Edm.Guid(Nullable=True,DefaultValue=))](Nullable=True,DefaultValue=)]' are not compatible. The IN expression only supports entity, primitive, and reference types.  

知道如何解决这个问题吗?

最佳答案

那是因为您不能将 IN 子句与 Guid(唯一标识符)类型一起使用。您的 UserId 是唯一标识符类型,因此请使用另一种不带 IN 的方式来检查它,例如临时表等。

尝试对表进行左连接,研究更多有关 SQL 的信息,这是一个示例:

SELECT  User.LastName,  User.Suffix  
FROM [User]
Left Join [Contractors] on [User].UserId = [Contractors].UserId
WHERE [Contractors].UserId IS NULL

我不确定这是否行得通,我现在无法对其进行测试。我确信有更好的方法来做我正在做的事情,但那是你遇到的错误....

关于c# - 在命令文本中使用 "not in"时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3863569/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com