public IEnumerable <TEntity> GetAll() { var sqlGenerator = new SqlGenerator <TEntity>(); var sql = sqlGenerator.GetSelectAllQuery(); var mapper = new NMapper.Mapper <TEntity>(); return(mapper.GetObjects(_commandGenerator.GetNpgsqlCommand(sql))); }
public TEntity Get(long id) { var sqlGenerator = new SqlGenerator <TEntity>(); var sql = sqlGenerator.GetSelectByIdQuery(); var mapper = new NMapper.Mapper <TEntity>(); var cmd = _commandGenerator.GetNpgsqlCommand(sql, new { id }); return(mapper.GetObject(cmd) ?? new TEntity()); }
public TEntity Find(Expression <Func <TEntity, object> > property, object value) { var sqlGen = new SqlGenerator <TEntity>(); var colunmName = GetCorrectPropertyName(property); var sql = sqlGen.GetSelectByColumnNameQuery(colunmName); var mapper = new NMapper.Mapper <TEntity>(); dynamic obj = new ExpandoObject(); var paramObj = (IDictionary <string, object>)obj; paramObj[colunmName] = value; var cmd = _commandGenerator.GetNpgsqlCommand(sql, obj); return(mapper.GetObject(cmd)); }
public IEnumerable <TEntity> GetAll(string sqlQuery, object param) { var mapper = new NMapper.Mapper <TEntity>(); return(mapper.GetObjects(_commandGenerator.GetNpgsqlCommand(sqlQuery, param))); }