I have an implementation of the TPT pattern using EF.
Once added the tables belonging to the TPT the InsertAll stopped working because there is an exception not handled when the EFMapping tries to handle a mapping belonging to the TPT.
if (mapping.EntityTypeMappings.Any(m => m.IsHierarchyMapping))
{
var withConditions = mapping.EntityTypeMappings.Where(m => m.Fragments[0].Conditions.Any()).ToList();
if (withConditions.Count > 0)
{
tableMapping.TPHConfiguration = new TPHConfiguration
{
ColumnName = withConditions.First().Fragments[0].Conditions[0].Column.Name,
Mappings = new Dictionary<Type, string>()
};
In the code below I show the point where it fails, the snippet shows also how I'm handling the issue, ignore the mapping if the condition withConditions.Count > 0 is false.
At this point in time I don't really need support for TPT, but of course it would make this library more complete. This quick fix in the code for now is doing the job because InsertAll will fail only if I try to add one of the Child Type belonging to the TPT.
I have an implementation of the TPT pattern using EF. Once added the tables belonging to the TPT the InsertAll stopped working because there is an exception not handled when the EFMapping tries to handle a mapping belonging to the TPT.
In the code below I show the point where it fails, the snippet shows also how I'm handling the issue, ignore the mapping if the condition withConditions.Count > 0 is false.
At this point in time I don't really need support for TPT, but of course it would make this library more complete. This quick fix in the code for now is doing the job because InsertAll will fail only if I try to add one of the Child Type belonging to the TPT.
For more info on TPT: MSDN - TPT