久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

錯誤,LINQ to Entities 不支持方法

Error, method not supported by LINQ to Entities(錯誤,LINQ to Entities 不支持方法)
本文介紹了錯誤,LINQ to Entities 不支持方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

為什么我會收到此錯誤:

Why I am getting this error:

LINQ to Entities 不支持方法Single".考慮使用First"方法.

           public ActionResult Details(int id)
Line 27:   {              
             var result = (from d in _db.MovieSet
Line 29:     where d.Id == id
Line 30:     select d).Single();
            //
            //
           } 

代碼編譯安全,但只有在調用相應部分時才會中斷.我是 LINQ 的新手,因此不知道哪些方法適用于 LINQtoSQL 或 LINQtoEntities.這意味著更多的錯誤!我們無法以這種方式記住所有方法.

Code compiles safe, but only breaks if call is made to the respective section. I am new to LINQ, therefore do not know which methods are for LINQtoSQL or LINQtoEntities. This means more errors! We cannot remember all methods this way.

我的問題是,如果適用于某些類型/場景的方法有限制,為什么它們會出現在 Intellisense 中?

My question is, if there are limitations to the methods applicable to certain types / scenarios, why do they appear in Intellisense?

任何有助于了解是否支持的解決方法/技術?

Any work-around / technique helpful to have an idea if one is supported ?

推薦答案

Microsoft 有一個完整的 Linq to Entities 中支持和不支持的方法列表.去那里可以找到這些信息.

Microsoft has a complete list of supported and unsupported methods in Linq to Entities. That's where to go to find out this information.

您會注意到 SingleSingleOrDefault 方法實際上在分頁方法部分被列為不支持".

You'll notice that the Single and SingleOrDefault methods are in fact listed as "not supported" in the section on Paging Methods.

正如 Jared 所指出的,編譯器在編譯時不知道您使用的是哪個提供程序,因此它無法強制執行提供程序可能實現或可能不實現的擴展方法的編譯時安全性.您將不得不依賴文檔.

As Jared pointed out, the compiler does not know at compile time which provider you are using, so it has no way to enforce compile-time safety of extension methods that the provider may or may not implement. You'll have to rely on the documentation instead.

這篇關于錯誤,LINQ to Entities 不支持方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 天天看天天爽 | 成人在线中文字幕 | 羞羞午夜 | 欧美日韩欧美 | 中文二区| 亚洲视频一区二区 | 手机日韩 | 999精品视频| 高清欧美性猛交xxxx黑人猛交 | 亚欧洲精品在线视频免费观看 | 亚洲成人免费在线观看 | 国产精品久久久久久久久久久久久 | 国产精品成人一区二区 | 亚洲成人精品国产 | 精品亚洲一区二区三区 | 欧美a在线观看 | 国产精品久久久久久久久 | 欧美在线视频网站 | 精品国产一区二区三区性色av | 国产高清在线精品一区二区三区 | 欧美成人精品欧美一级 | 国产午夜在线 | 欧美精品福利视频 | 亚洲成人久久久 | 黄色网址免费看 | 欧美一级免费片 | 国产成人精品一区二区三区在线 | 亚洲视频区 | 精品国产99 | 91久久久久 | 三级国产三级在线 | 91网在线播放 | 日韩欧美久久精品 | 四虎影视一区二区 | 国产99视频精品免费视频7 | japan21xxxxhd美女 日本欧美国产在线 | 日韩av大片免费看 | 三级视频网站 | 中文字幕日韩欧美一区二区三区 | 国产精品久久久久久久久久久免费看 | 免费久|