public void DecodeMemberAccessExpression() { Assert.That(ExpressionsHelper.DecodeMemberAccessExpression <TestingClass, int>(x => x.IntProp), Is.EqualTo(typeof(TestingClass).GetMember("IntProp")[0])); Assert.That(ExpressionsHelper.DecodeMemberAccessExpression <TestingClass, bool>(x => x.BoolProp), Is.EqualTo(typeof(TestingClass).GetMember("BoolProp")[0])); Assert.That(ExpressionsHelper.DecodeMemberAccessExpression <TestingClass, IEnumerable <string> >(x => x.CollectionProp), Is.EqualTo(typeof(TestingClass).GetMember("CollectionProp")[0])); }
public void Collection <TCollection>(Expression <Func <TEntity, TCollection> > collectionProperty, Action <IEntityCollectionCacheConfigurationProperties> collectionCacheConfiguration) where TCollection : IEnumerable { if (collectionProperty == null) { throw new ArgumentNullException("collectionProperty"); } var mi = ExpressionsHelper.DecodeMemberAccessExpression(collectionProperty); if (mi.DeclaringType != typeof(TEntity)) { throw new ArgumentOutOfRangeException("collectionProperty", "Collection not owned by " + typeof(TEntity).FullName); } var ecc = new EntityCollectionCacheConfigurationProperties(); collectionCacheConfiguration(ecc); collections.Add(typeof(TEntity).FullName + "." + mi.Name, ecc); }