English 中文(简体)
无法转换 IQueryable I 查询 <T> 无法计算,因为 T 具有“ 指导” 属性
原标题:Cannot convert IQueryable<T> AsEnumerable because T has a Guid property

我有以下EF类课程:

class Product
{
   public Guid ProductGuid { get; set; }
   public string ProductName { get; set; }
}

从 DB 类中衍生出 productionGuid 是 < strong > unigication 和 productionName 是 < strong> nvarchar 。

productext 作为上下文考虑:

var products = productContext.Products;
productList = products.ToList(); 

OR

productList = products.AsEnumerable(); 

第一个指令执行正确,第二个(两个)在运行时发布例外(它正确编译):

Unable to cast the type System.Guid to type System.Object . LINQ to Entities only supports casting Entity Data Model primitive types.

我尝试了所有没用的东西。我还有其他的“指导字段”的桌子,但是它从来没有启动过这样的例外。有什么原因呢?

问题回答

您真的需要在该属性中使用 GUID 类型吗? t 字符串会为您做吗?

尝试替换 GUID 。 用字符串代替 。





相关问题
Problem getting GUID string value in Linq-To-Entity query

I am trying to write a GUID value to a string in a linq select. The code can be seen below (where c.ID is GUID), but I get the following error: Unable to cast the type System.Guid to type System....

Sequential Guid Generator

Is there any way to get the functionality of the Sql Server 2005+ Sequential Guid generator without inserting records to read it back on round trip or invoking a native win dll call? I saw someone ...

.NET: Blog post on GUID?

I once read a blog post by a dev at Microsoft about the anatomy--what individual pieces of data are combined--of a System.Guid. Does anyone have the link? I m not finding it by googling.

Simple proof that GUID is not unique [closed]

I d like to prove that a GUID is not unique in a simple test program. I expected the following code to run for hours, but it s not working. How can I make it work? BigInteger begin = new BigInteger((...

Subsonic Linq guid problem

The construtor Void .ctor(System.Guid, Int32) is not supported. this error occured with the following statements: var Test = from r in db.UserRoles join p in db.UserPermissions on new { r....

热门标签