Beispiel #1
0
        public static async Task <List <dynamic> > ExecuteQueryAsync <T>(this T instance, string sql) where T : new()
        {
            var mereTable = MereUtils.CacheCheck <T>();

            var toReturn = new List <dynamic>();

            using (var myCn = mereTable.GetConnection())
            {
                var cmd = myCn.CreateCommand();

                cmd.CommandText = sql;
                await myCn.OpenAsync();

                using (var reader = new MereSqlDataReader <T>(await cmd.ExecuteReaderAsync()))
                {
                    while (reader.Read())
                    {
                        toReturn.Add((dynamic)reader);
                    }
                    myCn.Close();
                }
            }

            return(toReturn);
        }
Beispiel #2
0
        public static IEnumerable <dynamic> ExecuteCustomDynamicQueryToDynamic <T>(this T instance, string sql) where T : new()
        {
            var mereTable = MereUtils.CacheCheck <T>();

            var toReturn = new List <dynamic>();

            using (var myCn = mereTable.GetConnection())
            {
                var cmd = myCn.CreateCommand();

                cmd.CommandText = sql;
                myCn.Open();
                using (var reader = new MereSqlDataReader <T>(cmd.ExecuteReader()))
                {
                    while (reader.Read())
                    {
                        toReturn.Add((dynamic)reader);
                    }
                    myCn.Close();
                }
            }

            return(toReturn);
        }