예제 #1
0
        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)));
        }
예제 #2
0
        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());
        }
예제 #3
0
        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));
        }
예제 #4
0
        public IEnumerable <TEntity> GetAll(string sqlQuery, object param)
        {
            var mapper = new NMapper.Mapper <TEntity>();

            return(mapper.GetObjects(_commandGenerator.GetNpgsqlCommand(sqlQuery, param)));
        }