예제 #1
0
        public static IDbDataParameter[] ToParams(this CQuery query)
        {
            var pars = new List <IDbDataParameter>();

            query.Parameter.ToList().ForEach(p =>
                                             pars.Add(new SqlParameter(p.name, GetParameterValue(p))));

            return(pars.ToArray());
        }
예제 #2
0
        public static string ToSelectWhereString(this CQuery query, params IDbDataParameter[] pars)
        {
            if (query.isStoreProcedure)
            {
                return(query.name);
            }

            var q = query.Text;

            if (pars.Length > 0)
            {
                pars.ToList().ForEach(p =>
                {
                    q = q.Replace("{{" + p.ParameterName + "}}", p.QuoteValue());
                });
            }

            return(q);
        }
예제 #3
0
        public async Task <DataTable> LoadStoreProcedure(string connectionString, CQuery query, params IDbDataParameter[] pars)
        {
            using (var connection = new SqlConnection(connectionString))
            {
                using (var cmd = connection.CreateCommand())
                {
                    cmd.Connection.Open();
                    cmd.CommandText = query.Text;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddRange(pars);
                    var reader = await cmd.ExecuteReaderAsync();

                    var table = new DataTable(query.name);
                    table.Load(reader);
                    reader.Close();

                    return(table);
                }
            }
        }
예제 #4
0
 public Task <DataTable> LoadStoreProcedure(string dataSetName, CQuery query,
                                            params IDbDataParameter[] pars)
 {
     throw new NotImplementedException();
 }