In EF 4, the default ObjectSet is available for each entity. For example, I have table Employee, after gererated Entity Model, EF will create ObjectSet on Employee. Then when using wcf ria service, the default query will be like:
public IQueryable GetEmployee() { return this.ObjectContext.Employees; }
With objectSet, I can apply include on the result like:
return this.ObjectContext.Employees.Include("Department");
Then I create a stored procedure say MySearchForEmployee and import it as function. the result is mapped to entity Employee. When call the function, the result will be ResultSet, not ObjectSet.
I want to similar method available for domain service by call the stored procedure like:
public IQueryable<Employeer> GetMySearch(string keyword)
{
return this.ObjectContext.MySearchForEmployee(keyword).Include("Department");
}
But I can't becuase above code event can't pass syntax checking.
I tried following way to convet the result type:
var results = this.ObjectContext.MySearchForEmployee(keyword);
var objsets = (ObjectSet<Employee>) results;
then I got error as: Cannot convert type 'System.Data.Objects.ObjectResult' to 'System.Data.Objects.ObjectSet'
How to implement this request?