public override DbCommand CreateCommand(Database database) { var db = database; var cm = db.CreateCommand(); cm.CommandType = CommandType.StoredProcedure; cm.CommandText = this.GetStoredProcedureName(); DbParameter p = null; p = db.CreateParameter("@BigIntColumn", SqlDbType.BigInt, 19, 0); p.SourceColumn = p.ParameterName; p.Direction = ParameterDirection.InputOutput; p.Value = this.BigIntColumn; p.Value = p.Value ?? DBNull.Value; cm.Parameters.Add(p); p = db.CreateParameter("@StructuredColumn", SqlDbType.Structured, null, null); p.SourceColumn = p.ParameterName; p.Direction = ParameterDirection.Input; p.SetTypeName("MyTableType"); if (this.StructuredColumn.Records.Count > 0) { p.Value = this.StructuredColumn.CreateSqlDataRecords(this.StructuredColumn.Records); } cm.Parameters.Add(p); return(cm); }
public override DbCommand CreateCommand(Database database) { var db = database; var cm = db.CreateCommand(); cm.CommandType = CommandType.StoredProcedure; cm.CommandText = this.GetStoredProcedureName(); DbParameter p = null; p = db.CreateParameter("@BigIntColumn", SqlDbType.BigInt, 19, 0); p.SourceColumn = p.ParameterName; p.Direction = ParameterDirection.InputOutput; p.Value = this.BigIntColumn; cm.Parameters.Add(p); p = db.CreateParameter("@StructuredColumn", SqlDbType.Structured, null, null); p.SourceColumn = p.ParameterName; p.Direction = ParameterDirection.Input; p.SetTypeName("MyTableType"); { var dt = this.StructuredColumn.CreateDataTable(); foreach (var item in this.StructuredColumn.Records) { dt.Rows.Add(item.GetValues()); } p.Value = dt; } cm.Parameters.Add(p); for (int i = 0; i < cm.Parameters.Count; i++) { if (cm.Parameters[i].Value == null) { cm.Parameters[i].Value = DBNull.Value; } } return(cm); }