【发布时间】:2017-03-03 13:24:07
【问题描述】:
Tabella_Pratiche 是我的数据库的实体,P_ListLettore 是对象列表。
当我尝试加入 Tabella_Pratiche 和 P_ListLettore 时,我会产生异常。
Dim listPraticheEsistenti As List(Of Tabella_Pratiche)
listPraticheEsistenti = (From c In DB.Tabella_Pratiche Join b In P_ListLettore On c.posizione Equals b.AssignamentID And c.data_affido.ToString("dd/MM/yyyy") Equals b.R_RecordPA.Data_inizio_affidamento.ToString("dd/MM/yyyy") Where c.tipo_mandato = "SPG" Select c).ToList
例外“Eccezione non gestita di tipo EntityFramework.SqlServer.dll 中的“System.NotSupportedException”
Ulteriori information: Impossibile creare un valore costante di tipo 'ImportPratiche.RecordPrSPG'。 In questo Competitiono sono supportati solo Tipi primitivi o enumerazione。 "
【问题讨论】:
-
以后请提供英文异常信息。或者,如果您更喜欢用西班牙语交流,也可以使用Spanish SO(我知道这是意大利语,但我知道的只有这些)。该错误是因为您不能在内存列表和将使用 Linq to Sql 访问的列表之间使用连接语法(仍在数据库中)。如果你想要一个接近的等价物,你可以使用
Contains,它受支持并将被翻译成数据库上的IN子句,但这仅支持简单类型的列表,如int或string的列表。跨度> -
你能举个例子吗?
-
您也不能使用 ToString(""),这是一个 .net 概念,不会转换为 sql。这可能就是问题所在。我不会读意大利语,所以我在这里猜测,您的代码中可能还有其他问题。
-
我试过不使用 tostring 但我遇到了同样的问题