Domanda

I am new in using stored procedure using Microsoft Entity Framework. To do some practice I used Northwind database and I was successfully able to do something like this:

var qry = (from row in dbContext.CustOrderHist("custID").AsEnumerable()
    select row).Skip(10).Take(10);

Then I have my own DB I am working with it also has a few stored procedures and I similarly used the 'Add Function Import; feature of .Net to create ComplexType to get the stored procedure results (the way I practiced in Northwind Model).

But when I try to do the same:

var qry = (from row in _dbContext.spComplianceReport("SomeID", null).AsEnumerable()
    select row).Skip(10).Take(10);

It would not work, and gives error about AsEnumerable(). The following error:

System.Data.Objects.ObjectResult does not contain a definition for AsEnumerable and no extension method AsEnumerable accepting a first argument of type System.Data.Objects.ObjectResult could be found (are you missing a using directive or an assembly reference?)

This problem is with my every stored procedure in my Model. What can be different with my Model than the Northwind.

È stato utile?

Soluzione

Ok doing the following resolved my problem:

using System.Linq;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top