public IList <TEntity> AsListOfComplexModel <TEntity>(Action <TEntity, IReader> customFieldPopulator, params ICondition <TEntity>[] conditions) where TEntity : new() { return(SafeExec(() => { IModelBinder <TEntity> modelBinder = modelBinderFactory.Create(conditions); Reader reader = ExecuteReader(); var result = new List <TEntity>(); while (reader.Read()) { TEntity entity = modelBinder.BindReader( reader, () => { TEntity item = new TEntity(); customFieldPopulator(item, reader); return item; }); result.Add(entity); } return result; })); }
public TEntity AsModel <TEntity>(params ICondition <TEntity>[] conditions) where TEntity : new() { return(SafeExec(() => { IModelBinder <TEntity> modelBinder = modelBinderFactory.Create(conditions); var reader = ExecuteReader(); if (reader.Read()) { TEntity entity = modelBinder.BindReader(reader); return entity; } return default(TEntity); })); }
public IList <TEntity> AsListOfModel <TEntity>(params ICondition <TEntity>[] conditions) where TEntity : new() { return(SafeExec(() => { IModelBinder <TEntity> modelBinder = modelBinderFactory.Create(conditions); Reader reader = ExecuteReader(); var result = new List <TEntity>(); while (reader.Read()) { TEntity entity = modelBinder.BindReader(reader); result.Add(entity); } return result; })); }
public TEntity AsComplexModel <TEntity>(Action <TEntity, IReader> customFieldPopulator, params ICondition <TEntity>[] conditions) where TEntity : new() { return(SafeExec(() => { IModelBinder <TEntity> modelBinder = modelBinderFactory.Create(conditions); var reader = ExecuteReader(); if (reader.Read()) { TEntity entity = modelBinder.BindReader( reader, () => { TEntity item = new TEntity(); customFieldPopulator(item, reader); return item; }); return entity; } return default(TEntity); })); }