private void AssumeColumnNameMappingProfileIsInitialised()
 {
     this.itemMappingProfile = new EntityMappingProfile <InnerEntity>();
     this.itemMappingProfile.ForMember(e => e.Id, c => c.MapFromColumnName(InnerEntityIdColumnName, true))
     .ForMember(e => e.TestEntityId, c => c.MapFromColumnName(InnerEntityTestEntityIdColumnName))
     .ForMember(e => e.StringProperty,
                c => c.MapFromColumnName(InnerEntityStringPropertyColumnName))
     .ForMember(e => e.IntProperty, c => c.MapFromColumnName(InnerEntityIntPropertyColumnName));
 }
        public IEntityMappingProfile <T> ForMember <TMember>(Expression <Func <T, TMember> > selector,
                                                             IEntityMappingProfile mappingProfile)
            where TMember : class, new()
        {
            var memberInfo = selector.GetMemberExpression()
                             .Member;

            this.memberMappingProfiles.Add(memberInfo, mappingProfile);

            return(this);
        }
        public IEntityMappingProfile <T> ForGenericCollectionMember <TEnumerable, TItem>(
            Expression <Func <T, IEnumerable <TItem> > > selector,
            IEntityMappingProfile <TItem> mappingProfile)
            where TEnumerable : class, IEnumerable <TItem>, new() where TItem : class, new()
        {
            var memberInfo = selector.GetMemberExpression()
                             .Member;
            var mapper =
                new EntityGenericCollectionMemberMapper <TEnumerable, TItem>(memberInfo, mappingProfile);

            this.memberMappers.Add(memberInfo, mapper);

            return(this);
        }
        public IEntityMappingProfile <T> ForArrayMember <TItem>(
            Expression <Func <T, TItem[]> > selector,
            IEntityMappingProfile <TItem> mappingProfile)
            where TItem : class, new()
        {
            var memberInfo = selector.GetMemberExpression()
                             .Member;
            var mapper =
                new EntityArrayMemberMapper <TItem>(memberInfo, mappingProfile);

            this.memberMappers.Add(memberInfo, mapper);

            return(this);
        }
Пример #5
0
        public virtual IEnumerable <TEntity> Map <TEntity>(IDataReader reader)
            where TEntity : class, new()
        {
            if (this.mappingProfile == null)
            {
                this.mappingProfile = new DefaultEntityMappingProfile(typeof(TEntity));
            }

            var     list   = new List <TEntity>();
            TEntity entity = null;

            while (reader.Read())
            {
                if (entity == null || !this.mappingProfile.DataRecordMatchesEntity(entity, reader))
                {
                    entity = new TEntity();
                    list.Add(entity);
                }
                this.mappingProfile.Map(entity, reader);
            }

            return(list);
        }
Пример #6
0
 public void UseMappingProfile(IEntityMappingProfile mappingProfile)
 {
     this.mappingProfile = mappingProfile;
 }
Пример #7
0
 public IInsertStatement <TEntity> UsingMappingProfile(IEntityMappingProfile mappingProfile)
 {
     this.EntityMapper.UseMappingProfile(mappingProfile);
     return(this);
 }
Пример #8
0
 public IExecuteQueryProcedureStatement <TEntity> UsingMappingProfile(
     IEntityMappingProfile mappingProfile)
 {
     this.entityMapper.UseMappingProfile(mappingProfile);
     return(this);
 }
 public EntityArrayMemberMapper(MemberInfo memberInfo, IEntityMappingProfile <TItem> itemMappingProfile)
 {
     this.itemMappingProfile = itemMappingProfile;
     this.MemberInfo         = memberInfo;
 }
 public EntityGenericCollectionMemberMapper(MemberInfo memberInfo,
                                            IEntityMappingProfile <TItem> itemMappingProfile)
 {
     this.itemMappingProfile = itemMappingProfile;
     this.MemberInfo         = memberInfo;
 }