<强> 1比;排序信息丢失强>
如果在排序操作之后执行了任何其他操作,则不能保证这些附加操作中会保留排序结果。这些操作包括选择和等。另外,采用表达式作为输入参数的第一个和FirstOrDefault方法不保留顺序。
如下代码:并不能达到反序排序的效果
using (var edm =, new NorthwindEntities ()) { ,,,,IQueryable, cc =, edm.Customers.OrderByDescending (c =祝辞,c.CustomerID)。(c =祝辞,c.Region !=, null) .Select(=祝辞c c),,,,,, foreach (var c  cc)拷贝 ,,,,,,,,,Console.WriteLine (c.CustomerID); }
<强> 2比;不支持无符号整数强>
由于实体框架不支持无符号整数,因此不支持在LINQ to实体查询中指定无符号整数类型。如果指定无符号整数,则在查询表达式转换过程中会引发NotSupportedException异由于常,并显示无法创建类型为“结束类型”的常量值。此上下文仅支持基元类型(“例如Int32,字符串和Guid”)。
如下将会报异常的代码:
using (var edm =, new NorthwindEntities ()) ,{,,,,,uint id =, UInt32.Parse (“123”); ,,,,,IQueryable, produt =,得到p 拷贝edm.Products ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, where p.UnitPrice ==, id ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, select p.ProductName;,,,,,, foreach (string name 拷贝的产品) ,,,,,,,,,,,Console.WriteLine(名称); }
上面的代码中,由于id是使用uint而不是Int32,字符串,Guid的标量类型,所以在执行到p。UnitPrice id==这个地方时,会报异常。
3比;不支持引用非标量闭包
不支持在查询中引用非标量闭包(如实体)。在执行这类查询时,会引发NotSupportedException异由于常,并显示消息”无法创建类型为“结束类型”的常量值。此上下文中仅支持基元类型(“如Int32,字符串和Guid的)
如下将会报异常的代码:
using (var edm =, new NorthwindEntities ()) ,{ ,,,,,,,Customers customer =, edm.Customers.FirstOrDefault (); ,,,,,,,IQueryable, cc =,得到c 拷贝edm.Customers ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, where c ==, customer ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, select c.ContactName;,,,,,,,,, foreach (string name  cc)拷贝 ,,,,,,,,,,,,,,Console.WriteLine(名称); }
上面的代码中,由于客户是引用类型而不是Int32,字符串,Guid的标量类型,所以在执行到c==客户这个地方时,会报异常。