I can implement that restriction even if unneeded... ;)
The code used by this method
public void Property<TProperty>(Expression<Func<TEntity, TProperty>>
property)
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
will be the same code executed after this
public void Property<TProperty>(string propertyOrFieldName)
{
MemberInfo member =
typeof(TEntity).GetPropertyOfFieldMatchingName(propertyOrFieldName)
if(member == null)
{
throw new ArgumentOutOfRangeException("propertyOrFieldName", "the property
or field........");
}
On Thu, Apr 28, 2011 at 11:57 AM, Stephen Bohlen <[email protected]> wrote:
> In this case, the "Something" string might *either* refer to a private
> field or a private/protected property, is that right --?
>
> Steve Bohlen
> [email protected]
> http://blog.unhandled-exceptions.com
> http://twitter.com/sbohlen
>
>
>
> On Thu, Apr 28, 2011 at 10:24 AM, Richard Brown (gmail) <
> [email protected]> wrote:
>
>> +1 for strings ... it also enables using reflection based usage on the
>> API.
>>
>> *From:* Fabio Maulo <[email protected]>
>> *Sent:* Thursday, April 28, 2011 12:20 PM
>> *To:* [email protected]
>> *Subject:* [nhibernate-development] Mapping by-code protected/private
>> members
>> To explicit map private field I done this
>> ca.Property(ForClass<MyClass>.Field("something"), map => map.Length(150));
>>
>>
>> To explicit map private/protected properties I should do something like
>> this
>> ca.Property(ForClass<MyClass>.Property("Something"), map =>
>> map.Length(150));
>>
>> The matter is that at the end, if we don't want an "invasion" to the users
>> domain-model (and I would always avoid it), we end with a string
>> representing the private/protected member-name.
>> Using the ConventionModelMapper there is "no problem" if the user can
>> accept to write the mapping catching that member in the BeforeMapProperty
>> event (or similar for others relations).
>>
>> I would introduce a short-cut
>> ca.Property("Something", map => map.Length(150));
>>
>> Thoughts ?
>>
>> --
>> Fabio Maulo
>>
>>
>
--
Fabio Maulo