Possible Duplicate:
Get values in NotMapped property in model class Entity Framwork Code First using linq
I am using Entity Framework 5
's Code First
in my project and my model looks more or less like this:
public class Category
{
public int CategoryId { get; set; }
public string Name { get; set; }
public virtual Category Parent { get; set; }
[NotMapped]
public int Level { get; set; }
}
The generated table
contains all columns except the Level column
(as expected)
Now, I have a stored procedure
which calculates the Level of the Category node in relation to it's parent.
If I execute the stored procedure
in SQL Server Mgmt Studio it returns the columns as specified in my model including the [NotMapped] Level column
.
The thing is: the Level column
is not filled if I call the stored procedure
like this: Context.Database.SqlQuery<TModel>(storedProcedure, parameterArray);
where TModel
is Category
.
Is there any way to 're-use' this Category model
?