0

The Entity Framework has a function with this signature:

public EntityTypeConfiguration<TEntityType> HasKey<TKey>(Expression<Func<TEntityType, TKey>> keyExpression);

If your table has a clustered primary key you can represent that like this:

this.HasKey(t => new { t.Field1, t.Field2 });

My question is, how are they consuming this anonymous type? I would like to build some similar functionality in methods of my own, that allow a lambda expression that returns multiple properties.

Is there some special way to peek into an anonymous type?

4

1 に答える 1

2

They just use reflection.

For additional performance, you can use expression trees to store pre-compiled delegates in a generic type.

于 2012-06-15T12:33:16.207 に答える