[英]Is it possible to use a Data context in the immediate window of Visual Studio 2017?
I'm trying to debug C# Linq 2 SQL code, and i'm getting a "System.NotSupportedException" exception when using Last() on a table. 我正在尝试调试C#Linq 2 SQL代码,并且在表上使用Last()时遇到“ System.NotSupportedException”异常。 Is it not possible to use this operator in the Immediate windows of Visual Studio 2017? 在Visual Studio 2017的即时窗口中无法使用此运算符吗?
I just tried a quick test using LinqPad and can confirm that Linq to SQL does not have a translation for .Last()
, instead it throws an exception with the message "The query operator 'Last' is not supported." 我刚刚使用LinqPad进行了快速测试,并且可以确认Linq to SQL没有.Last()
的转换,相反,它抛出异常,消息为“不支持查询运算符'Last'。”
If you have a incremental type primary id such an integere or another field that's indexed and easy to order by, instead perhaps try doing a .OrderByDescending(x => x.id).First()
如果您具有增量类型的主ID,例如整数或其他易于索引的字段,则可以尝试执行.OrderByDescending(x => x.id).First()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.