Category:Pakistani dances
Category:Muhajir communities
Category:Muhajir cultureQ:
Identity 2.0 Storing OData results in EDM
Is it possible to store some results from an OData query in an EDM model?
So I have a model that has a one to many relationship with another model, say 'Results'. I want to be able to query the results of the query from the model, and store some of the results in the Results model.
A:
I have a similar setup but using Code First instead of Database First.
With Database First it was possible to use Stored Procedure or views but Code First does not support it directly.
I think there are 2 ways to achieve what you are trying to do.
Set up a stored procedure that stores the result data in the database. Set the IsStoredProcedure property of the Result entity to true and use code first to map it to your entity (it does that for you).
In your Database First model, add a stored procedure to insert data from the OData query in the corresponding table. Add a Result entity mapping with the appropriate code first properties.
So if you have an Entity called A and Entity called B the Result entity mapping could look like this:
class Result
{
[Key]
public int Id { get; set; }
public int AId { get; set; }
public virtual A A { get; set; }
public int BId { get; set; }
public virtual B B { get; set; }
}
Database first
If you set the Result.IsStoredProcedure property to true then you can't map it to an entity. But you can map a stored procedure to an entity.
Your Result entity mapping can look like this:
class Result
{
[Key]
public int Id { get; set; }
public int AId { get; set; }
public virtual A A { get; set; }
public int BId { get; set; }
public virtual B B { get; set; }
public bool IsStoredProcedure { get; set; }
public be359ba680
Related links:
Comments