C# EF6:ObjectContext.ExecuteStoreQuery返回空列表
我有以下情况: 在数据库中:C# EF6:ObjectContext.ExecuteStoreQuery返回空列表,c#,sql-server,entity-framework,C#,Sql Server,Entity Framework,我有以下情况: 在数据库中: 存储过程:gp\u get\u位置 在我的项目(EF6)中,我有一个DbContext对象 public List<Location> GetLocation(int LocationId, int Top = 100) { var prmLocationID = new SqlParameter("location_id", SqlDbType.Int) { Value = LocationId };
- 存储过程:gp\u get\u位置
- 在我的项目(EF6)中,我有一个DbContext对象
执行上下文函数:public List<Location> GetLocation(int LocationId, int Top = 100) { var prmLocationID = new SqlParameter("location_id", SqlDbType.Int) { Value = LocationId }; var prmTop = new SqlParameter("top", SqlDbType.Int) { Value = Top }; ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = 300; var query = ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreQuery<Location>(@"EXECUTE [dbo].[gp_get_location] @location_id, @top", prmLocationID, prmTop); return query.ToList(); }
GetLocation(X, 100) //returns 100 results GetLocation(Y, 100) //NOT CORRECT - returns 0 results, no exception no warning just 0
这种奇怪行为的原因可能是什么?我怎样才能找到根源呢?这是一个非常古老的问题,似乎从来没有人回答过。我假设你已经修好了,但以防万一,检查一下你的定位对象。确保成员是属性而不是字段GetLocation(X, 100) //returns 100 results GetLocation(Y, 100) //NOT CORRECT - returns 0 results, no exception no warning just 0