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()); }
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); }
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); } } }
public Task <DataTable> LoadStoreProcedure(string dataSetName, CQuery query, params IDbDataParameter[] pars) { throw new NotImplementedException(); }