コード例 #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
ファイル: DataSetDataSource.cs プロジェクト: forki/Labs
 public Task <DataTable> LoadStoreProcedure(string dataSetName, CQuery query,
                                            params IDbDataParameter[] pars)
 {
     throw new NotImplementedException();
 }