只有LINQ to Entities中的排序输入才支持“Skip”方法。必须在方法“跳过”之前调用“OrderBy”方法 [英] The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'
问题描述
$ p
$ b $ p
$ p
$ b $ p $ b
DefaultModel.RegisterContext(typeof(masterEntities1),new ContextConfiguration(){ScaffoldAllTables = true});
当我运行一个应用程序,它显示一个表的列表,但是当我点击任何一个表抛出异常:
仅在LINQ to Entities中排序输入支持跳过方法。必须在方法跳过之前调用OrderBy方法。
但是我没有在我的应用程序中声明任何查询。
如果您使用的话,您必须调用 .OrderBy'
.Skip
方法。例如,如果您使用类似于以下内容:
results = results.Skip(pageNumber * size).Take(size);
在上述情况下,您以前必须使用 .OrderBy
订单该查询是否正在计划使用分页方法或类似的东西。如果您有一个 Id
字段,请将其添加到原始查询表达式中,以消除错误:
.OrderBy(x => x.Id);
I am working on a Dynamic data.
after creating a dynamic model and registering in global.asax, like
DefaultModel.RegisterContext(typeof(masterEntities1),new ContextConfiguration() { ScaffoldAllTables = true });
when i run an application, it shows a list of tables but when i click any of the table it throws an exception:
The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.
but i haven't declare any query into my application.
You must call .OrderBy'
on your query if you use the .Skip
method. For example if you were using something similar to the following:
results = results.Skip(pageNumber * size).Take(size);
In the case above you would have previously had to use the .OrderBy
to order the query if you are planning on using paging methods or something of the like. If you have an Id
field, adding this onto your original query expression should eliminate the error:
.OrderBy(x => x.Id);
这篇关于只有LINQ to Entities中的排序输入才支持“Skip”方法。必须在方法“跳过”之前调用“OrderBy”方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!