Пример #1
0
        public List <T> Find(string where, params DbParameter[] dbParameters)
        {
            var result      = new List <T>();
            var queryResult = SqlHelper.Query(where, dbParameters);

            foreach (var item in queryResult)
            {
                var model = JsonDataConvert.DeSerializeObject <T>((string)item.data);
                result.Add(model);
            }
            return(result);
        }
Пример #2
0
        public T Get(string id)
        {
            var sql         = $"select data::text from {table} where id = @id";
            var queryResult = SqlHelper.Query(sql, new NpgsqlParameter
            {
                ParameterName = "id",
                NpgsqlDbType  = NpgsqlDbType.Text,
                NpgsqlValue   = id
            });

            if (queryResult.Any())
            {
                return(JsonDataConvert.DeSerializeObject <T>((string)(queryResult.FirstOrDefault().data)));
            }
            return(null);
        }