How to map a List<int> to a ModificationMapping SP for Insert in EF4?
I have an entity with
Entity
{
int Id;
object otherProperties;
List<int> ForeignIds;
}
I have written an Insert SP that takes:
@Id INT,
@ForeignId INT
How can I map a List to a SP for Insert for a Modification Mapping that would insert a row with the Id
and an element from ForeignIds
for each element in ForeignId
?
E.g.
Entity(){ id=1; For开发者_如何学CeignIds = new List<int>(){2,3};}
Would insert:
Id | ForeignId
1 | 2 1 | 3You cannot map this. EF doesn't understand List
of scalar types. You must manually iterate the list and execute stored procedure for each item in the collection. You can map the procedure as function import or execute it directly by objectContext.ExecuteStoreCommand
.
精彩评论