You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test that materialization, etc.handles entities that use C# 6 features #1311
I tried adding test in EntityMaterializerSourceTest which contains entity with read only auto properties. It throws following exception
System.InvalidOperationException : No backing field could be discovered for property 'Microsoft.Data.Entity.Tests.Metadata.EntityMaterializerSourceTest+SomeEntityReadOnly.Foo' and the property does not have a setter. Either use a backing field name that can be matched by convention, annotate the property with a backing field, or define a property setter.
@smitpatel I think for that particular case it is expected. We would probably need materialization to support matching constructor parameters to be able to work with those entities. It may be a good idea to file a bug for that and then we can discuss the priority.
Given that the semantics of getter-only auto properties are the same as readonly fields, should we even be trying to set these fields in the first place?
Discussed in triage and agreed that we should not include a getter-only property in the model by convention. Logged these two issues as a result of the discussion:
Activity
rowanmiller commentedon Jan 9, 2015
Please discuss with @ajcvickers
Also summarize what you tested (and findings) at design meeting
smitpatel commentedon Jan 21, 2015
I tried adding test in EntityMaterializerSourceTest which contains entity with read only auto properties. It throws following exception
divega commentedon Jan 22, 2015
@smitpatel I think for that particular case it is expected. We would probably need materialization to support matching constructor parameters to be able to work with those entities. It may be a good idea to file a bug for that and then we can discuss the priority.
smitpatel commentedon Jan 24, 2015
It is possible to find backing field of read-only auto property through reflection.
The backing field is constructed using pattern k__BackingField
Following method gives access to backing field.
Then we can use this code to set the value
smitpatel commentedon Jan 24, 2015
Marking for re-triage to decide what to do next for this.
bricelam commentedon Jan 24, 2015
Given that the semantics of getter-only auto properties are the same as
readonlyfields, should we even be trying to set these fields in the first place?ilmax commentedon Jan 24, 2015
+1 for materialization via constructor. This is a good feature and lot of people would like to have this.
rowanmiller commentedon Feb 2, 2015
Discussed in triage and agreed that we should not include a getter-only property in the model by convention. Logged these two issues as a result of the discussion:
divega commentedon May 11, 2016
Clearing up milestone so that we can review this in triage.