Call mapper.Class<TEntity>(Property) via Reflection

12 views
Skip to first unread message

Matteo Migliore

unread,
May 28, 2011, 1:53:46 PM5/28/11
to ConfORM
Hi!

How can I call the method Property of this class using Reflection or
another way?

I've the "TEntity" parameter and the PropertyInfo or a
MemberExpression.

Thanks a lot!

Matteo Migliore

unread,
May 28, 2011, 2:02:09 PM5/28/11
to ConfORM
I found this article but it explains how to retrieve a Func<TEntity,
object> not an Expression<Func<TEntity, object>>:
http://weblogs.asp.net/marianor/archive/2009/04/10/using-expression-trees-to-get-property-getter-and-setters.aspx

Fabio Maulo

unread,
May 28, 2011, 3:37:23 PM5/28/11
to codec...@googlegroups.com
eh?
--
Fabio Maulo

Matteo Migliore

unread,
May 28, 2011, 3:56:43 PM5/28/11
to ConfORM
I think I solved the problem.

I'm creating an agnostic mapping system.

I've this class:
class CustomerMapping : IEntityMapping<Customer>
{
public CustomerMapping()
{
Property(p => p.FirstName)
.Lenght(200);
}
}

The method Property save the property in a List<PropertyInfo>, then in
a second moment I've to call the method
mapper.Class<TEntity>(c => c.Property), but I've a PropertyInfo not an
Expression<Funct<TEntity, object>>.

My problem was how to call the ConfOrm method transforming the
PropertyInfo to an Expression<Funct<TEntity, object>>.

Now (I hope, I need more tests) that I can make this "conversion".

On May 28, 9:37 pm, Fabio Maulo <fabioma...@gmail.com> wrote:
> eh?
>
> On Sat, May 28, 2011 at 2:53 PM, Matteo Migliore
> <matteo.migli...@gmail.com>wrote:

Fabio Maulo

unread,
May 28, 2011, 5:32:09 PM5/28/11
to codec...@googlegroups.com
bah?!?
--
Fabio Maulo

Reply all
Reply to author
Forward
0 new messages