自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

異常ADO.NET代碼的解釋說明

開發(fā) 后端
本文向大家介紹ADO.NET代碼,可能好多人還不了解ADO.NET代碼,沒有關(guān)系,看完本文你肯定有不少收獲,希望本文能教會你更多東西。

 隨著時(shí)代的進(jìn)步科技的發(fā)展ADO.NET代碼 版本也快速的提升與升級,下面我就對升級前和升級后的ADO.NET代碼,做一下自己的解析。希望能夠?qū)Υ蠹矣袔椭旅婢瓦M(jìn)行解釋說明。

最近在用ADO.NET代碼操作數(shù)據(jù)時(shí)發(fā)現(xiàn)有很多都不能用上,前幾天也發(fā)現(xiàn)一些但沒有記下來,今天又出現(xiàn)了,我決定在博客園里把它記下來。這些功能 在LINQ TO SQL中可以用但在ADO.NET ENTITY FRAMEWORK 中確不能用。

今天在用到模糊查詢時(shí)有用到  in模式的查詢時(shí)突然出現(xiàn)異常代碼如下:

  1. int[] intArray = {1,2,3,4,5,6,7,8,9,10,11,12,13,14 };  
  2. var query = from a in  AdonetContext.Products //Products 為實(shí)體類(表名)  
  3. where intArray.Contains(a.FID)  
  4. select a;  
  5. IEnumable<Product> lists=query.ToList();  

當(dāng)執(zhí)行到query.ToList()時(shí)(因?yàn)槭茄舆t執(zhí)行所以會在ToList方法時(shí)才直正執(zhí)行查詢)出現(xiàn)異常:

 LINQ to Entities does not recognize the method 'Boolean Contains[Int32](System.Collections.Generic.IEnumerable`1[System.Int32], Int32)' method, and this method cannot be translated into a store expression#t#

而 這句話如果用ADO.NET代碼的話則可以正確執(zhí)行最近生成的SQL語句為:

  1. exec sp_executesql N'SELECT [t0].[FID], [t0].[FProName], [t0].[FManufacturer], [t0].[FCategory], [t0].[FProDate], [t0].[FPrice]  
  2. FROM [dbo].[Products] AS [t0]  
  3. WHERE [t0].[FID] IN (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13)  
  4. ORDER BY [t0].[FID] DESC',N'@p0 int,@p1 int,@p2 int,@p3 int,@p4 int,@p5 int,@p6 int,@p7 int,@p8 int,@p9 int,@p10 int,@p11 int,@p12 int,@p13   
  5. int',@p0=1,@p1=2,@p2=3,@p3=4,@p4=5,@p5=6,@p6=7,@p7=8,@p8=9,@p9=10,@p10=11,@p11=12,@p12=13,@p13=14 

 

責(zé)任編輯:chenqingxiang 來源: 網(wǎng)易博客
相關(guān)推薦

2009-12-22 14:52:54

ADO.NET腳本

2009-12-23 15:13:15

Ado.Net Syb

2009-12-18 14:01:07

ADO.NET體系結(jié)構(gòu)

2009-12-21 11:29:13

Ado.Net代碼

2009-12-23 17:39:16

ADO.NET解決方案

2009-12-30 15:17:06

ADO.NET選項(xiàng)

2009-12-21 17:29:43

ADO.NET模型

2009-12-24 09:34:47

調(diào)用ADO.NET

2009-12-22 17:43:26

ADO.Net技術(shù)

2009-12-30 16:05:20

ADO.NET實(shí)例

2009-12-22 11:17:58

ADO.NET產(chǎn)品

2010-01-05 10:30:28

ADO.NET數(shù)據(jù)庫連

2009-12-21 10:37:05

Ado.Net 實(shí)例

2009-12-21 14:55:49

ADO.NET對象

2009-12-31 14:18:46

ADO.NET類庫

2010-01-04 09:03:57

ADO.NET連接對象

2009-12-22 09:15:02

ADO.NET功能

2009-12-30 15:11:35

ADO.NET數(shù)據(jù)

2009-12-21 14:55:49

ADO.NET屬性

2010-01-04 13:16:31

ADO.NET命令
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號