Пример #1
0
        public object Get(string sqlQuery, Type type)
        {
            if (type.GetTypeInfo().IsValueType || type == typeof(String))
            {
                return(ExecuteQuery(sqlQuery));
            }

            if (TypeSystem.IsList(type))
            {
                var elementType = TypeSystem.GetElementType(type);
                return(ExecuteReader(sqlQuery, sdr =>
                {
                    var data = TypeSystem.CreateList(elementType);
                    while (sdr.Read())
                    {
                        data.Add(Load(sdr, elementType));
                    }
                    return data;
                }));
            }

            return(ExecuteReader(sqlQuery, sdr =>
            {
                if (sdr.Read())
                {
                    return Load(sdr, type);
                }
                return null;
            }));
        }