- Where Developers Learn, Share, & Build Careers


How do I get my property? Currently a code has got a suspicious match , see the comment row in the code.

  Public category MyBaseEntity {public MyBaseEntity MyEntity {get; Set; }} Public category MyDerivedEntity: MyBaseEntity {public New MyDerivedEntity MyEntity {get; Set; }} Private Static Zero Main (string [] Args) {MyDerivedEntity myDE = New MyDerivedEntity (); PropertyInfoPenFofofostown = myDE.GetType (). GetProperty ("MyEntity"); // - Error: Unmatched matching found}    

< P> Such situations in which ambiguity arises ...

... Derivative types declare a property that hides a successive property with the same name, using the new modifier

If you run the following

  var properties = myDE.GetType (). GetProperties (). Where (P = & gt; p.Name == "MyEntity");   

You will notice that the two PropertyInfo objects are returned. One is for MyBaseEntity another MyDerivedEntity . This is the reason that you are receiving suspicious match error.

You can get to MyDerivedEntity for PropertyInfo this way:

  propertyfile propinfoSrcObj = myDE .GetType () GetProperties (). Single (P = & gt; P. Name == "Myintitude" & amp; amp; amp; amp; amp; P. Property Type == Type (MyDerivedEntity);    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -