question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fluent Property Ignores Don't Work on Interfaces or Inherited Classes

See original GitHub issue

Describe the bug If you a base class, or interface, that describes columns for entities, then use the Fluent interface to ignore properties in that class, it won’t ignore them. Using attributes will.

To Reproduce For the entity:

public class MyTest {
      public string MyField { get;set;}
}

public class MyInheritedEntity : MyTest {

}

And the configuration

Configuration.Setup().ForContext<ApplicationDbContext>(config =>
                    config.ForEntity<MyTest>(x => x
                        .Ignore(y => y.MyField)
                    )
           );

The field MyField will be included in the changes even though it should not be.

Expected behavior MyField should not be included in the changes section.

Libraries (specify the Audit.NET extensions being used including version): For example:

  • Audit.EntityFramework: 14.0.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iamwyzacommented, Dec 19, 2018

I can see the reasons why this would add alot of extra bulk to the project. Thanks for thinking it through and considering it.

0reactions
thepirat000commented, Dec 12, 2018

I still don’t feel this is something worth implementing.

The entity classes (in your case the derived classes) can be configured explicitly one by one, just like you do for EF or any other ORM framework. I see no advantage in providing such mechanism (inheritance and precendence of property attributes) for classes that just represents entities in a relational database.

Still open to validate and eventually merge any pull request you want to contribute.

Regards

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fluent Nhibernate AutoMapping Inheritance and Ignoring ...
Now i am trying to auto map the inherited relationship, it automatically maps the abstract property to the child classes, but this is...
Read more >
Problems with joinedsubclass
Making an override for one of the derived classes (to use ignore property as per your recommendation yesterday) the ignoreproperty doesnt work, the...
Read more >
Inherited property cannot be excluded or included when ...
When a derive class implements an interface through an inherited property, the property cannot be excluded by .Excluding() or included by .
Read more >
Fluent API - Configuring and Mapping Properties and Types
This article is designed to demonstrate how to use the fluent API to configure properties. The code first fluent API is most commonly...
Read more >
[Webinar Recording] Mistake-Proof Your Code with Fluent ...
Our guest Scott Lilly will walk you through the topic of fluent interfaces and demonstrate how it can save you from needing to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found