Hi,
I have a question related to IReadOnlyCollection<> and backing fields. Say i have the following situation:
public class Car
{
private ICollection<Tire> _tires = new HashSet<Tire>();
public IReadOnlyCollection<Tire> Tires
{
get { return new ReadOnlyCollection<Tire>(_tires.ToList()); }
}
public void AddTire(Tire tire)
{
_tires.Add(tire);
}
}
What i want is to be able to use indexes on Tires field and serialize and deserialize the value from and into _tires.
With NHibernate i am able to do this by specifying the access, for example in Fluent NHibernate it will be:
HasMany(x => x.Tires).Access.CamelCaseField(Prefix.Underscore);
I have looked into JsonContractResolver but lack the knowledge to find it out.
Does some have suggestions how to tackle this situation?