I'm trying to map a value object collection where these contain other value objects but am getting the below exception.
nHibernate Exception:
----> NHibernate.PropertyNotFoundException : Could not find a getter for property '_timeAtAddress' in class 'CustomerAddress'
Domain:
public class CustomerAddress
{
private TimePeriod _timeAtAddress;
protected CustomerAddress() { }
public CustomerAddress(TimePeriod timeAtAddress)
{
_timeAtAddress = timeAtAddress;
}
public TimePeriod TimeAtAddress { get { return _timeAtAddress; } }
}
public class TimePeriod
{
private readonly int _months;
private readonly int _years;
protected TimePeriod() { }
public TimePeriod(int months, int years)
{
_months = months;
_years = years;
}
public int Months { get { return _months; } }
public int Years { get { return _years; } }
}
nHibernate Mapping:
contact.HasMany<CustomerAddress>(Reveal.Member<Contact>("_customerAddresses"))
.Schema(...)
.Table(...)
.KeyColumn(...)
.AsBag()
.Not.LazyLoad()
.Component(address =>
{
.
.
.
address.Component(Reveal.Member<CustomerAddress, TimePeriod>("_timeAtAddress"), timeAtAddress =>
{
timeAtAddress.Map(Reveal.Member<TimePeriod>("_years")).Column("TIME_YEARS");
timeAtAddress.Map(Reveal.Member<TimePeriod>("_months")).Column("TIME_MONTHS");
});
});
Had a quick look at Access but can't seem to figure out where to set that up for components. Can you help?
With the map function, we map every element of the array to the custom components in a single line of code. That means there is no need to call components and their props as array elements again and again. Syntax: var array = [1,2,3,4,5] var PlusOne= array.
To use a map() inside a map() function in React: Call map() on the outer array, passing it a function. On each iteration, call the map() method on the other array.
In React, the map method is used to traverse and display a list of similar objects of a component. A map is not a feature of React. Instead, it is the standard JavaScript function that could be called on an array. The map() method creates a new array by calling a provided function on every element in the calling array.
The answer is, you use Array. map() in your component and return JSX elements inside the Array. map() callback function to render the UI.
Rather than configuring FluentNHibernate to set the private field, shouldn't you be telling it to use the constructor argument?
My gut feeling is that the mistake is here:
address.Component(Reveal.Member<CustomerAddress, TimePeriod>("_timeAtAddress")
Where you're telling it to use the field _timeAtAddress
.
The only way I managed to move forward (using the private field) was to set a global Access.Field convention.
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Customer>()
.Conventions.Add(DefaultAccess.Field()))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With