Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to TPT or handle error on EFMapping #103

Open
norcino opened this issue Nov 10, 2016 · 0 comments
Open

Add support to TPT or handle error on EFMapping #103

norcino opened this issue Nov 10, 2016 · 0 comments

Comments

@norcino
Copy link

norcino commented Nov 10, 2016

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.

For more info on TPT: MSDN - TPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant