public MockTable(TableName name) { this.name = name; columns = new ColumnCollection(this); rows = new Dictionary<RowId, TableRow>(); rowIndex = new List<RowId>(); }
public static TableName[] Search(string pattern, TableName[] tableNames) { Regex regex = pattern.WildcardRegex(); var result = tableNames.Where(tname => regex.IsMatch(tname.Name)).ToArray(); return result; }
public bool Includes(TableName tableName) { if (Excludedtables == null) return true; return !Excludedtables.IsMatch(tableName.ShortName); }
public SystemTable CreateTable(TableName tableName) { CheckNotDisposed(); // Check the table name given is qualified CheckTableNameQualified(tableName); // Does an object with this name already exist in the directory? ITable tables = GetTable(SystemTableNames.Tables); IRowCursor ind = GetNames(tables, tableName); if (ind.Count > 0) throw new ApplicationException("Table '" + tableName + "' already exists."); ITable table = state.CreateTable(tableName); if (table == null) throw new ApplicationException("The table '" + tableName + "' was not created."); long tableId = state.CreateUniqueId(SystemTableNames.Tables); // Construct and create the table SystemTable sysTable = new SystemTable(this, table, tableId); // Add this table to the tables. AddObject(tableId, tableName, "TABLE"); // Log the change in the journal journal.AddEntry(JournalCommandCode.TableCreate, tableId); OnChanged(); // Put it in the cache tableNameMap[tableName] = sysTable; // And return it return sysTable; }
protected TableBase(TableName tableName) { this.tableName = tableName; columns = new ColumnCollection(this); DoSetupColumns(); }
public Exporter(PathManager mgr, TreeNode<IDataPath> pt, Configuration cfg) { this.mgr = mgr; this.cfg = cfg; this.xml = new XmlDbFile { XmlDbFolder = cfg.XmlDbFolder }; this.fileName = cfg.OutputFile; if (pt.Item is Locator) { this.tname = mgr.GetPathFrom<TableName>(pt); this.dname = tname.DatabaseName; this.sname = dname.ServerName; } else if (pt.Item is TableName) { this.tname = (TableName)pt.Item; this.dname = tname.DatabaseName; this.sname = dname.ServerName; } else if (pt.Item is DatabaseName) { this.tname = null; this.dname = (DatabaseName)pt.Item; this.sname = dname.ServerName; } else if (pt.Item is ServerName) { this.tname = null; this.dname = null; this.sname = (ServerName)pt.Item; } }
/// <summary> /// Reads all rows out of multiple local flat-files for the specified date range and table name /// </summary> /// <param name="startDay">The start day and time to grab rows from.</param> /// <param name="endDay">The end day and time to grab rows from.</param> /// <param name="name">Name of the table to grab data from.</param> /// <returns>Returns a DataSet that contains all rows that were created inbetween the start and end datetime stamps</returns> public static DataSet ReadRange(DateTime startDay, DateTime endDay, TableName name) { DataTable table; if (startDay > endDay) { throw new ArgumentOutOfRangeException("startDay", "startDay cannot be newer than endDay"); } DataSet set = new DataSet(); if (startDay.Date < endDay.Date) { table = ReadDay(startDay, name, true); if (table != null) { set.Tables.Add(table); } startDay = startDay.Date.AddDays(1.0); } while (startDay < endDay) { table = ReadDay(startDay, name, true); if (table != null) { set.Tables.Add(table); } startDay = startDay.AddDays(1.0); } if (startDay.Date == endDay.Date) { table = ReadDay(endDay, name, false); if (table != null) { set.Tables.Add(table); } endDay = new DateTime(endDay.Year, endDay.Month, endDay.Day, 0x17, 0x3b, 0x3b); } return set; }
public static string Difference(DataProvider from, DataProvider to, string dbNameFrom, string dbNameTo) { DatabaseName dname1 = new DatabaseName(from, dbNameFrom); DatabaseName dname2 = new DatabaseName(to, dbNameTo); string[] names = MetaDatabase.GetTableNames(dname1); StringBuilder builder = new StringBuilder(); foreach (string tableName in names) { TableName tname1 = new TableName(dname1, tableName); TableName tname2 = new TableName(dname2, tableName); string[] primaryKeys = InformationSchema.PrimaryKeySchema(tname1).ToArray<string>(0); if (primaryKeys.Length == 0) continue; if (MetaDatabase.TableExists(tname2)) { builder.Append(TableCompare.Difference(tname1, tname2, tableName, primaryKeys)); } else { builder.Append(TableCompare.Rows(tableName, from)); } builder.AppendLine(); } return builder.ToString(); }
/// <summary> /// Register Logee Implement /// </summary> /// <param name="tableName"></param> /// <param name="tableId"></param> /// <param name="logee"></param> public void Register(TableName tableName, IRowLogee logee) { if (rowLogees.ContainsKey(tableName)) rowLogees.Remove(tableName); rowLogees.Add(tableName, logee); }
internal IntegrityRule(TableName name, TableName tableName, IntegrityRuleKind kind, string[] columnNames) { this.name = name; this.columnNames = columnNames; this.kind = kind; this.tableName = tableName; }
public static DataTable SqlTableSchema(TableName tableName) { DataTable dt1; string SQL = string.Format(SQL_SCHEMA, "", "WHERE t.name='{0}'"); dt1 = Use(tableName, SQL); return dt1; }
public Variable(TableName tableName, string columnName) { if (tableName == null || columnName == null) { throw new ArgumentNullException(); } this.table_name = tableName; this.column_name = columnName; }
public AliasTableNameExpression(Expression child, TableName alias, SqlType returnType) : base(ExpressionType.AliasTableName) { SetArgument("child", child); SetArgument("alias", alias); if (returnType != null) SetArgument("return_type", returnType); }
/// <summary> /// use default locator to save records into database, primary keys must be defined /// </summary> /// <param name="tableName"></param> public TableWriter(TableName tableName) { this.schema = tableName.GetTableSchema(); IPrimaryKeys primary = schema.PrimaryKeys; if (primary.Length != 0) this.locator = new Locator(primary); }
public virtual bool Exists(TableName tname) { DatabaseName dname = tname.DatabaseName; if (!Exists(dname)) return false; return GetTableNames(dname).FirstOrDefault(row => row.Equals(tname)) != null; }
public BaseRowAdapter(TableName tname, Locator locator) { this.columns = new ColumnAdapterCollection(); this.fields = new DataFieldCollection(); this.tableName = tname; this.locator = locator; }
public ForeignKey(TableName sourceTable, string[] sourceColumns, TableName refTableName, string[] destColumns, string updateAction, string deleteAction, bool deferrable, bool deferred) : base(sourceTable, ConstraintType.ForeignKey, sourceColumns, deferrable, deferred) { this.deleteAction = deleteAction; this.updateAction = updateAction; this.destColumns = destColumns; this.refTableName = refTableName; }
public void HandleAttributeOverride() { var attrib = Type.GetSingleAttribute<TableAttribute>(false); if (attrib == null) return; Table = new TableName(attrib.Name,attrib.DbSchema); IdentityColumn = attrib.IdentityColumn; }
public Constraint(TableName tableName, string name, ConstraintType type, string[] columns, bool deferrable, bool deferred) { this.tableName = tableName; this.columns = (string[]) columns.Clone(); this.type = type; this.name = name; this.deferrable = deferrable; this.deferred = deferred; }
public TableAdapter(DataTable dataTable, TableName tableName, Locator locator) { this.dataTable = dataTable; this.tableName = tableName; this.locator = locator; this.columns = new ColumnAdapterCollection(); this.fields = new DataFieldCollection(); }
public string CompareTable(ActionType actiontype, CompareSideType sidetype, TableName tname1, TableName tname2, Dictionary<string, string[]> pk, string[] exceptColumns) { TableSchema schema1 = new TableSchema(tname1); TableSchema schema2 = new TableSchema(tname2); if (!Exists(tname1)) return string.Empty; string sql = string.Empty; if (actiontype == ActionType.CompareSchema) { sql = Compare.TableSchemaDifference(sidetype, tname1, tname2); stdio.WriteLine("completed to {0} table schema {1} => {2}", sidetype, tname1, tname2); } else if (actiontype == ActionType.CompareData) { if (!Exists(tname2)) { return string.Empty; } if (Compare.TableSchemaDifference(sidetype, tname1, tname2) != string.Empty) { stdio.WriteLine("failed to {0} becuase of different table schemas", sidetype); return string.Empty; } bool hasPk = schema1.PrimaryKeys.Length > 0; sql = Compare.TableDifference(sidetype, schema1, schema2, schema1.PrimaryKeys.Keys, exceptColumns); if (!hasPk) { stdio.WriteLine("warning: no primary key found : {0}", tname1); string key = tname1.Name.ToUpper(); if (pk.ContainsKey(key)) { stdio.WriteLine("use predefine keys defined in ini file: {0}", tname1); sql = Compare.TableDifference(sidetype, schema1, schema2, pk[key], exceptColumns); } else { stdio.WriteLine("use entire row as primary keys:{0}", tname1); var keys = schema1.Columns.Select(row => row.ColumnName).ToArray(); sql = Compare.TableDifference(sidetype, schema1, schema2, keys, exceptColumns); } } stdio.WriteLine("completed to {0} table data {1} => {2}", sidetype, tname1, tname2); } if (sql != string.Empty && sidetype == CompareSideType.compare) stdio.WriteLine(sql); return sql; }
public string EscapeTableName(TableName table) { var schema = ""; if (!table.Schema.IsNullOrEmpty()) { schema = Escape(table.Schema,EscapeChars.Start,EscapeChars.End)+"."; } return schema + Escape(table.Name,EscapeChars.Start, EscapeChars.End); }
public void GenerateField() { string fieldName = column.ToFieldName(); string ty = ColumnSchema.GetFieldType(column.DataType, column.Nullable); Property prop = new Property(new CodeBuilder.TypeInfo { userType = ty }, fieldName); if (dpoClass.option.HasColumnAttribute || column.ColumnName != fieldName) { var attr = prop.AddAttribute<ColumnAttribute>(); Attribute(attr, column); attr.comment = new Comment(string.Format("{0}({1}) {2}", column.DataType, column.AdjuestedLength(), column.Nullable ? "null" : "not null")); } if (dpoClass.Nonvalized.IndexOf(fieldName) != -1) prop.AddAttribute<NonValizedAttribute>(); //When programmer make field Nullable, it must be Nullable //if(dgc.NullableFields.IndexOf(fieldName) != -1) // nullable = true; dpoClass.clss.Add(prop); dpoClass.dict_column_field.Add(column.ColumnName, new PropertyDefinition(ty, fieldName)); if (column.ForeignKey != null && dpoClass.Dict != null) { TableName pkTableName = new TableName( column.ForeignKey.TableName.DatabaseName, column.ForeignKey.PK_Schema, column.ForeignKey.PK_Table); //column.ForeignKey.TableName; if (dpoClass.Dict.ContainsKey(pkTableName)) { Type type = dpoClass.Dict[pkTableName]; ForeignKey.GetAttribute(column.ForeignKey, type); } else { //### //ForeignKey check for external Dpo classes, they don't be load into dict //var log = new LogDpoClass(pkTableName); //if (log.Exists) //{ // string classFullName = string.Format("{0}.{1}", log.name_space, log.class_name); // line = string.Format("{0}{1}\r\n", tab, ForeignKey.GetAttribute(column.ForeignKey, classFullName)) + line; //} //else throw new MessageException("cannot generate Dpo class of FK {0} before generate Dpo class of PK {1}", dpoClass.MetaTable.TableName, pkTableName); } } return; }
internal ComputedColumns(TableName tname) { string SQL = @" USE [{0}] SELECT c.name FROM sys.tables t JOIN sys.columns c ON t.object_id = c.object_id WHERE t.name = '{1}' AND c.is_computed = 1"; this.columnNames = DataExtension.FillDataTable(tname.Provider, SQL, tname.DatabaseName.Name, tname.Name).ToArray<string>(0); }
public Logger(Transaction transaction, DPObject dpo) { this.log_transaction = transaction; this.tableName = dpo.TableName; this.tableId = dpo.TableId; this.rowID = dpo.RowId; this.logee = LogManager.Instance.RowLogee(dpo); dpoType = dpo.GetType(); }
public SystemTable GetTable(TableName tableName) { CheckNotDisposed(); CheckTableNameQualified(tableName); SystemTable table = InternalGetTable(tableName); if (table == null) throw new ArgumentException("Table '" + tableName + "' not found."); return table; }
public Logger(Transaction transaction, TableName tableName, string rowIdColumnName, int rowID) { this.log_transaction = transaction; this.tableName = tableName; this.tableId = this.tableName.Id; this.rowID = rowID; this.logee = LogManager.Instance.RowLogee(tableName); this.rowIdColumnName = rowIdColumnName; }
public string Write(TableName tname, DataTable dt) { string file = getDataFileName(tname); using (var writer = NewStreamWriter(file)) { dt.TableName = tname.Name; dt.DataSet.DataSetName = tname.DatabaseName.Name; dt.WriteXml(writer, XmlWriteMode.WriteSchema); } return file; }
public void DropTable(TableName tableName) { CheckNotDisposed(); // Check the table name given is qualified CheckTableNameQualified(tableName); // Get the id of the table long table_id = GetTableId(tableName); // Drop the table DropTable(table_id); }
public ForeignKey(TableName tableName, IColumn column) { this.TableName = tableName; ColumnSchema schema = (ColumnSchema)column; this.FK_Column = column.ColumnName; this.PK_Schema = schema.PK_Schema; this.PK_Table = schema.PK_Table; this.PK_Column = schema.PK_Column; this.Constraint_Name = schema.FkContraintName; }
public static DataTable DependenySchema(this TableName tname) { string WHERE = string.Format("WHERE PK.TABLE_SCHEMA='{0}' AND PK.TABLE_NAME='{1}'", tname.SchemaName, tname.Name); return(Use(tname, SQL_FK_QUERY + WHERE)); }
/// <summary> /// register user defined record/row logee /// </summary> /// <param name="tableName"></param> /// <param name="logee"></param> public static void Register(this TableName tableName, IRowLogee logee) { LogManager.Instance.Register(tableName, logee); }
public void Execute(int transactionId) { var freebal = new TableName { MethodName = "FreeBalance", ModuleName = "Balances" }; var curValueRow = new TableRow { RowName = "value", BlockNumber = _pex.BlockNumber }; BigInteger curValue = 0; var sval = _dbAdapter.GetLastStorageValue(freebal, curValueRow); if (!sval.Equals("")) { curValue = BigInteger.Parse(sval); } var part1 = new TableRow { RowName = "value", BlockNumber = _pex.BlockNumber, Value = new List <string> { (amount + curValue).ToString() } }; _dbAdapter.InsertIntoStorage(freebal, part1); var transactionSenderKey = new TableRow { RowIndex = 0, RowName = "Sender", Value = new List <string> { sk } }; var transfer = new TableName { MethodName = "bond_extra", ModuleName = "Staking" }; var tid = new TableRow { RowIndex = 1, RowName = "transactionindex", Value = new List <string> { transactionId.ToString() } }; var maxAdditional = new TableRow { RowIndex = 1, RowName = "max_additional", Value = new List <string> { amount.ToString() } }; var blocknumber = new TableRow { RowIndex = 1, RowName = "blocknumber", Value = new List <string> { _pex.BlockNumber.ToString() } }; var nonce = new TableRow { RowIndex = 0, RowName = "Nonce", Value = new List <string> { _pex.Nonce.ToString() } }; var signatureKey = new TableRow { RowIndex = 0, RowName = "Signature", Value = new List <string> { _pex.Signature } }; var status = new TableRow { RowIndex = 0, RowName = "Status", Value = new List <string> { _pex.Status.ToString() } }; var blockHash = new TableRow { RowIndex = 0, RowName = "Block", Value = new List <string> { _pex.BlockHash.ToString() } }; _dbAdapter.InsertIntoCall(transfer, new List <TableRow> { blockHash, tid, signatureKey, status, nonce, transactionSenderKey, maxAdditional, blocknumber }); }
// Insert Data Function public string InsertWithImage(TableName tableName, string[] fields, string[] values) { try { Connect(); SqlCommand command; SqlDataAdapter adapter; //SqlDataReader reader = null; string commandText = string.Empty; string table = string.Empty; switch (tableName) { case TableName.Users: table = "TBUsers"; break; case TableName.Registration: table = "TBRegistration"; break; case TableName.TheTamThoi: table = "TBTheTamThoi"; break; default: break; } StringBuilder builder = new StringBuilder($"INSERT INTO [DBBaiDoXe].[dbo].[{table}]("); for (int i = 0; i < fields.Length; i++) { builder.Append(i == fields.Length - 1 ? $"[{fields[i]}]) VALUES(" : $"[{fields[i]}],"); } for (int i = 0; i < values.Length; i++) { builder.Append(i != values.Length - 1 ? $"@{fields[i]}, " : $"@{fields[i]})"); } commandText = builder.ToString(); command = new SqlCommand(commandText, sqlConnection); for (int i = 0; i < values.Length; i++) { if (fields[i] == "HinhAnh") { command.Parameters.AddWithValue(fields[i], string.IsNullOrEmpty(values[i]) ? (object)DBNull.Value : GetData(values[i])).SqlDbType = SqlDbType.Image; } else { command.Parameters.AddWithValue(fields[i], values[i]); } } adapter = new SqlDataAdapter(command); adapter.InsertCommand = new SqlCommand(commandText, sqlConnection); //adapter.InsertCommand.ExecuteNonQuery(); command.ExecuteNonQuery(); command.Dispose(); sqlConnection.Close(); return(string.Empty); } catch (Exception ex) { return(ex.Message); } }
public History(TableName tableName, IProviderMetadata providerMetadata) { _tableName = tableName; _providerMetadata = providerMetadata; }
private static string Escape(TableName tableName) { string schemaPrefix = tableName.Schema != null ? "\"" + tableName.Schema + "\"." : string.Empty; return(schemaPrefix + "\"" + tableName.Name + "\""); }
/// <summary> /// 获取哈希码。 /// </summary> /// <returns>返回 32 位整数。</returns> public override int GetHashCode() => Schema.CompatibleGetHashCode() ^ TableName.CompatibleGetHashCode();
public override int GetHashCode() { return(Schema.GetHashCode() + TableName.GetHashCode() + ColumnName.GetHashCode()); }
public void Execute(int transactionId) { var fTransfer = new TableName { ModuleName = "Identity", MethodName = "set_account_id" }; var indexRow = new TableRow { RowIndex = 0, RowName = "index", Value = new List <string> { index } }; var newValueRow = new TableRow { RowIndex = 0, RowName = "new", Value = new List <string> { newValue } }; var tid = new TableRow { RowIndex = 1, RowName = "transactionindex", Value = new List <string> { transactionId.ToString() } }; var blocknumber = new TableRow { RowIndex = 0, RowName = "blocknumber", Value = new List <string> { pex.BlockNumber.ToString() } }; var nonce = new TableRow { RowIndex = 0, RowName = "Nonce", Value = new List <string> { pex.Nonce.ToString() } }; var signatureKey = new TableRow { RowIndex = 0, RowName = "Signature", Value = new List <string> { pex.Signature } }; var status = new TableRow { RowIndex = 0, RowName = "Status", Value = new List <string> { pex.Status.ToString() } }; var transactionSenderKey = new TableRow { RowIndex = 0, RowName = "Sender", Value = new List <string> { sk } }; var blockHash = new TableRow { RowIndex = 0, RowName = "Block", Value = new List <string> { pex.BlockHash.ToString() } }; _dbAdapter.InsertIntoCall(fTransfer, new List <TableRow> { blockHash, tid, transactionSenderKey, status, nonce, signatureKey, newValueRow, indexRow, blocknumber }); }
public override string ToString() { try { StringBuilder boBuilder = new StringBuilder(); boBuilder.AppendLine(Constants.USING_Base); boBuilder.AppendLine(Constants.USING_BaseBO); boBuilder.AppendLine("using System;"); boBuilder.Append("using "); boBuilder.AppendFormat(Constants.DL_NAMESPACE_FORMAT, NameSpace); boBuilder.AppendLine(";"); boBuilder.AppendLine(); boBuilder.AppendFormat("namespace {0}\n", string.Format(Constants.BO_NAMESPACE_FORMAT, NameSpace)); boBuilder.AppendLine("{"); boBuilder.AppendFormat("\tpublic class {0} : {1}\n", TableName.Replace(" ", ""), Constants.BaseBO); boBuilder.Append("\t{\n"); string str; foreach (Column col in TableColumns) { str = col.ToString(); boBuilder.Append(str); str = ""; } boBuilder.AppendFormat("\t\tpublic override string {0}()\n", Constants.GET_TABLE_NAME_METHOD); boBuilder.Append("\t\t{\n\t\t\t"); boBuilder.AppendFormat("return \"{0}\";\n", TableName); boBuilder.AppendLine("\t\t}"); boBuilder.AppendLine(); boBuilder.AppendFormat("\t\tpublic override string {0}()\n", Constants.GET_ID_COLUMN_METHOD); boBuilder.Append("\t\t{\n\t\t\t"); boBuilder.AppendFormat("return \"{0}\";\n", IdColumn); boBuilder.AppendLine("\t\t}"); boBuilder.AppendLine(); boBuilder.AppendLine(MethodString("int", "Insert")); boBuilder.AppendLine(MethodString("int", "InsertAndGetId")); boBuilder.AppendLine(MethodString("int", "Update")); boBuilder.AppendLine(MethodString("int", "Delete")); /* * boBuilder.AppendLine("\t\tpublic int Insert()\n\t\t{"); * // starting try block * boBuilder.AppendLine("\t\t\ttry\n\t\t\t{"); * boBuilder.AppendFormat("\t\t\t\treturn (new {0}DL(this)).Insert();\n", TableName.Trim()); * // ending try block * boBuilder.AppendLine("\t\t\t}"); * // starting-ending catch block * boBuilder.AppendLine("\t\t\tcatch\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}"); * boBuilder.AppendLine("\t\t}\n"); * * boBuilder.AppendLine("\t\tpublic int InsertAndGetId()\n\t\t{"); * // starting try block * boBuilder.AppendLine("\t\t\ttry\n\t\t\t{"); * boBuilder.AppendFormat("\t\t\t\treturn (new {0}DL(this)).InsertAndGetId();\n", TableName.Trim()); * // ending try block * boBuilder.AppendLine("\t\t\t}"); * // starting-ending catch block * boBuilder.AppendLine("\t\t\tcatch\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}"); * boBuilder.AppendLine("\t\t}\n"); * * boBuilder.AppendLine("\t\tpublic int Update()\n\t\t{"); * // starting try block * boBuilder.AppendLine("\t\t\ttry\n\t\t\t{"); * boBuilder.AppendFormat("\t\t\t\treturn (new {0}DL(this)).Update();\n", TableName.Trim()); * // ending try block * boBuilder.AppendLine("\t\t\t}"); * // starting-ending catch block * boBuilder.AppendLine("\t\t\tcatch\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}"); * boBuilder.AppendLine("\t\t}\n"); * * boBuilder.AppendLine("\t\tpublic int Delete()\n\t\t{"); * // starting try block * boBuilder.AppendLine("\t\t\ttry\n\t\t\t{"); * boBuilder.AppendFormat("\t\t\treturn (new {0}DL(this)).Delete();\n", TableName.Trim()); * // ending try block * boBuilder.AppendLine("\t\t\t}"); * // starting-ending catch block * boBuilder.AppendLine("\t\t\tcatch\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}"); * boBuilder.AppendLine("\t\t}\n"); */ boBuilder.AppendLine("\t}"); boBuilder.Append("}"); return(boBuilder.ToString()); } catch (Exception) { throw; } }
/// <inheritdoc /> public override int GetHashCode() { return((TableName?.GetHashCode() ?? 0) | (ChangeLogContext?.GetHashCode() ?? 0) | (Expression?.GetHashCode() ?? 0)); }
/// <summary> /// 获取命名空间 /// </summary> /// <param name="baseNamespace">基命名空间</param> /// <param name="layer">层</param> /// <param name="category">分类</param> public string GetNamespace(string baseNamespace, string layer, string category = "") => string.IsNullOrWhiteSpace(TableName) || TableName.ToLower().Trim() == "dbo" ? $"{baseNamespace}.{layer}{GetCategory(category)}" : $"{baseNamespace}{TableSchema}{layer}{GetCategory(category)}";
public static void DropTable(string tableName) { DropTable(TableName.Parse(tableName)); }
void PageInit() { DataTable dataTableField; bool isValidate; bool isAdd; isAdd = true; if (TableName.Substring(0, 4) == "K_F_") { displayListVisible = "display:block;"; foreach (ListItem item in radlBasicField.Items) { if (item.Value == "3" || item.Value == "11" || item.Value == "12" || item.Value == "14") { item.Enabled = false; } } } if (IsSub == "1") { foreach (ListItem item in radlBasicField.Items) { if (item.Value == "14") { item.Enabled = false; } } } if (this.Action.ToLower() == "edit") { isAdd = false; isValidate = IsHaveRightByOperCode("Edit"); // 修改权限认证 if (!isValidate) { jsMessage = "errmsg=\"对不起,您没有修改模型的操作权限,请与管理员联系!\";id=\"" + ID + "\""; } } else { isValidate = IsHaveRightByOperCode("New"); // 添加权限认证 if (!isValidate) { jsMessage = "errmsg=\"对不起,您没有添加模型的操作权限,请与管理员联系!\";id=\"" + ID + "\""; } } fieldManage.SubModelBind(ddlSubModelName); // 子模型列表绑定 fieldManage.SubModelGroupBind(ddlSubModelGroup); // 子模型分组绑定 fieldManage.ModelFieldGroupBind(ddlModelFieldGroupId); // 字段分组 hdnModelID.Value = ModelID; fieldManage.ValidationTypeBind(radlValidationType); // 绑定验证规则 dataTableField = fieldManage.DropDownDataTypeBind(ddlDropDownTable, null); // 绑定数据表 ddlDropDownTextColumn.DataTextField = "Name"; // 绑定Text列 ddlDropDownTextColumn.DataValueField = "Name"; ddlDropDownTextColumn.DataSource = dataTableField; ddlDropDownTextColumn.DataBind(); ddlDropDownValueColumn.DataTextField = "Name"; // 绑定Value列 ddlDropDownValueColumn.DataValueField = "Name"; ddlDropDownValueColumn.DataSource = dataTableField; ddlDropDownValueColumn.DataBind(); ddlDropDownTextColumn.Items.Insert(0, "请选择数据表"); if (!isAdd) // 编辑 { DataTable dtField; KingTop.Model.SelectParams selParam; selParam = new KingTop.Model.SelectParams(); selParam.S1 = ID; hdnAction.Value = "edit"; btnModelField.Text = "修改"; dtField = fieldManage.GetList("ONE", selParam); if (dtField != null && dtField.Rows.Count > 0) { hdnBasicField.Value = dtField.Rows[0]["BasicField"].ToString().Trim(); BasicFieldInit(dtField.Rows[0]); CommonFieldInit(dtField.Rows[0]); } else { jsMessage = "errmsg=\"对不起,参数传递有误!\";id=\"" + ID + "\""; } } else // 添加 { hdnAction.Value = "add"; } }
public override void ExecuteCmdlet() { var dataExportParameters = new CreatePSDataExportParameters(ResourceGroupName, WorkspaceName, DataExportName, TableName.ToList(), ResourceId, EventHubName, Enable); if (ShouldProcess(DataExportName, $"Create Data export: {DataExportName}, in workspace: {WorkspaceName}, resource group: {ResourceGroupName}")) { WriteObject(this.OperationalInsightsClient.CreateDataExport(ResourceGroupName, dataExportParameters), true); } }
public string MethodString(string returnType, string methodName) { StringBuilder mthdBuilder = new StringBuilder(); mthdBuilder.AppendFormat("\t\tinternal {0} {1}()\n\t\t", returnType, methodName); mthdBuilder.AppendLine("{"); // starting try block mthdBuilder.AppendLine("\t\t\ttry\n\t\t\t{"); mthdBuilder.AppendFormat("\t\t\t\tusing({0}DL _{1}dlDL = new {0}DL())\n", TableName.Replace(" ", ""), TableName.Replace(" ", "").ToLower()); mthdBuilder.AppendLine("\t\t\t\t{"); mthdBuilder.AppendFormat("\t\t\t\t\treturn _{0}dlDL.{1}(this);\n", TableName.Replace(" ", "").ToLower(), methodName); mthdBuilder.AppendLine("\t\t\t\t}"); // ending try block mthdBuilder.AppendLine("\t\t\t}"); // starting-ending catch block mthdBuilder.AppendLine("\t\t\tcatch (Exception)\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}"); mthdBuilder.AppendLine("\t\t}"); return(mthdBuilder.ToString()); }
void Init() { var ta = _mappingSchema.GetAttribute <TableAttribute>(TypeAccessor.Type, a => a.Configuration); if (ta == null) { TableName = TypeAccessor.Type.Name; if (TypeAccessor.Type.IsInterface && TableName.Length > 1 && TableName[0] == 'I') { TableName = TableName.Substring(1); } } else { TableName = ta.Name; SchemaName = ta.Schema; DatabaseName = ta.Database; IsColumnAttributeRequired = ta.IsColumnAttributeRequired; } var attrs = new List <ColumnAttribute>(); foreach (var member in TypeAccessor.Members) { var aa = _mappingSchema.GetAttribute <AssociationAttribute>(member.MemberInfo, attr => attr.Configuration); if (aa != null) { Associations.Add(new AssociationDescriptor( TypeAccessor.Type, member.MemberInfo, aa.GetThisKeys(), aa.GetOtherKeys(), aa.Storage, aa.CanBeNull)); continue; } var ca = _mappingSchema.GetAttribute <ColumnAttribute>(member.MemberInfo, attr => attr.Configuration); if (ca != null) { if (ca.IsColumn) { if (ca.MemberName != null) { attrs.Add(new ColumnAttribute(member.Name, ca)); } else { var cd = new ColumnDescriptor(_mappingSchema, ca, member); Columns.Add(cd); _columnNames.Add(member.Name, cd); } } } else if ( !IsColumnAttributeRequired && _mappingSchema.IsScalarType(member.Type) || _mappingSchema.GetAttribute <IdentityAttribute> (member.MemberInfo, attr => attr.Configuration) != null || _mappingSchema.GetAttribute <PrimaryKeyAttribute>(member.MemberInfo, attr => attr.Configuration) != null) { var cd = new ColumnDescriptor(_mappingSchema, new ColumnAttribute(), member); Columns.Add(cd); _columnNames.Add(member.Name, cd); } } var typeColumnAttrs = _mappingSchema.GetAttributes <ColumnAttribute>(TypeAccessor.Type, a => a.Configuration); foreach (var attr in typeColumnAttrs.Concat(attrs)) { if (attr.IsColumn) { SetColumn(attr); } } }
public void Execute(int transactionId) { var fb = new TableName { ModuleName = "Balances", MethodName = "FreeBalance" }; var rb = new TableName { ModuleName = "Balances", MethodName = "ReservedBalance" }; var ti = new TableName { ModuleName = "Balances", MethodName = "TotalIssuance" }; _dbAdapter.InsertIntoStorage(fb, new TableRow { BlockNumber = pex.BlockNumber, RowName = "value", Value = new List <string> { newFree } }); _dbAdapter.InsertIntoStorage(rb, new TableRow { BlockNumber = pex.BlockNumber, RowName = "value", Value = new List <string> { newReserved } }); var bsb = new TableName { ModuleName = "Balances", MethodName = "set_balance" }; var who = new TableRow { RowIndex = 0, RowName = "who", Value = new List <string> { rk } }; var nFree = new TableRow { RowIndex = 0, RowName = "new_free", Value = new List <string> { newFree } }; var nReserved = new TableRow { RowIndex = 0, RowName = "new_reserved", Value = new List <string> { newReserved } }; var tid = new TableRow { RowIndex = 1, RowName = "transactionindex", Value = new List <string> { transactionId.ToString() } }; var transactionSenderKey = new TableRow { RowIndex = 0, RowName = "Sender", Value = new List <string> { sk } }; var blocknumber = new TableRow { RowIndex = 0, RowName = "blocknumber", Value = new List <string> { pex.BlockNumber.ToString() } }; var nonce = new TableRow { RowIndex = 0, RowName = "Nonce", Value = new List <string> { pex.Nonce.ToString() } }; var signatureKey = new TableRow { RowIndex = 0, RowName = "Signature", Value = new List <string> { pex.Signature } }; var status = new TableRow { RowIndex = 0, RowName = "Status", Value = new List <string> { pex.Status.ToString() } }; var blockHash = new TableRow { RowIndex = 0, RowName = "Block", Value = new List <string> { pex.BlockHash.ToString() } }; _dbAdapter.InsertIntoCall(bsb, new List <TableRow> { blockHash, tid, status, nonce, signatureKey, who, nFree, nReserved, blocknumber, transactionSenderKey }); }
public static string ForeignKeyTo <TEntity>() where TEntity : class, IEntity { var tableName = TableName.ForEntity <TEntity>(); return($"{tableName}Id"); }
public async Task DeleteTable(TableName tableName, List <KeyValuePair <string, string> > parameters) { await ReadTable(tableName); string clusterName = string.Empty; string serverName = string.Empty; string json = string.Empty; switch (tableName) { case TableName.TBL_CLUSTER: foreach (var a in parameters) { if (a.Key.Equals("clusterName", StringComparison.OrdinalIgnoreCase)) { clusterName = a.Value; } } TBL_CLUSTER.Delete(new TBL_CLUSTER_KEY { clusterName = clusterName }); json = TBL_CLUSTER.GetJson(); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + tableName.ToString() + ".txt"), json); break; case TableName.TBL_SERVER: foreach (var a in parameters) { if (a.Key.Equals("serverName", StringComparison.OrdinalIgnoreCase)) { serverName = a.Value; } } TBL_SERVER.Delete(new TBL_SERVER_KEY { serverName = serverName }); json = TBL_SERVER.GetJson(); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + tableName.ToString() + ".txt"), json); break; case TableName.TBL_CLUSTER_SERVER: foreach (var a in parameters) { if (a.Key.Equals("clusterName", StringComparison.OrdinalIgnoreCase)) { clusterName = a.Value; } if (a.Key.Equals("serverName", StringComparison.OrdinalIgnoreCase)) { serverName = a.Value; } } TBL_CLUSTER_SERVER.Delete(new TBL_CLUSTER_SERVER_KEY { clusterName = clusterName, serverName = serverName }); json = TBL_CLUSTER_SERVER.GetJson(); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + tableName.ToString() + ".txt"), json); break; default: throw new ArgumentOutOfRangeException("unknown table"); } await UploadFileToObject(tableName); }
public static DataTable RetrieveTable(string serverName, string databaseName, TableName parentTableName, Dictionary <string, List <string> > keysAndValues, DataTable primaryKeyConstraints) {// TODO move this logic into RetrieveTableWhereKeysInValues DataTable dataTable = new DataTable(); if (keysAndValues.Count > 0) { // Determine primary key constraints List <string> primaryKeyColumnNames = DataReader.GetListOfPrimaryKeyConstraints(parentTableName.Schema, parentTableName.Name, primaryKeyConstraints).Select(row => row["ColumnName"].ToString()).ToList(); dataTable = DataReader.RetrieveTableWhereKeysInValues(serverName, databaseName, parentTableName, keysAndValues, primaryKeyColumnNames); } else { //Write-Host "Table $parentTableNameDelimited not retrieved. $childTableNameDelimited.[$(foreignKeyConstraint.ConstraintColumnName)] values are all DBNull"; todo } return(dataTable); }
public async Task UpSertTable(TableName tableName, List <KeyValuePair <string, string> > parameters) { await ReadTable(tableName); string clusterName = "NULL"; string serverName = "NULL"; string clusterNo = "NULL"; string domainName = "NULL"; string clusterPort = "NULL"; string serverInstanceNo = "NULL"; string serverPublicIp = "NULL"; string serverPrivateIp = "NULL"; string serverPort = "NULL"; string serverUserId = "NULL"; string serverPassword = "******"; string serverAliasName = "NULL"; string regionNo = "NULL"; string zoneNo = "NULL"; string serverImageProductCode = "NULL"; string serverProductCode = "NULL"; string feeSystemTypeCode = "NULL"; string loginKeyName = "NULL"; string accessControlGroupConfigurationNoList_1 = "NULL"; string accessControlGroupConfigurationNoList_2 = "NULL"; string accessControlGroupConfigurationNoList_3 = "NULL"; string accessControlGroupConfigurationNoList_4 = "NULL"; string accessControlGroupConfigurationNoList_5 = "NULL"; string serverRole = "NULL"; string json = string.Empty; switch (tableName) { case TableName.TBL_CLUSTER: foreach (var a in parameters) { if (a.Key.Equals("clusterName", StringComparison.OrdinalIgnoreCase)) { clusterName = a.Value; } if (a.Key.Equals("clusterNo", StringComparison.OrdinalIgnoreCase)) { clusterNo = a.Value; } if (a.Key.Equals("domainName", StringComparison.OrdinalIgnoreCase)) { domainName = a.Value; } if (a.Key.Equals("clusterPort", StringComparison.OrdinalIgnoreCase)) { clusterPort = a.Value; } } TBL_CLUSTER.Insert( new TBL_CLUSTER_KEY { clusterName = clusterName } , new TBL_CLUSTER_VALUE { clusterNo = clusterNo, domainName = domainName, clusterPort = clusterPort }); json = TBL_CLUSTER.GetJson(); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + tableName.ToString() + ".txt"), json); break; case TableName.TBL_SERVER: foreach (var a in parameters) { if (a.Key.Equals("serverName", StringComparison.OrdinalIgnoreCase)) { serverName = a.Value; } if (a.Key.Equals("serverInstanceNo", StringComparison.OrdinalIgnoreCase)) { serverInstanceNo = a.Value; } if (a.Key.Equals("serverPublicIp", StringComparison.OrdinalIgnoreCase)) { serverPublicIp = a.Value; } if (a.Key.Equals("serverPrivateIp", StringComparison.OrdinalIgnoreCase)) { serverPrivateIp = a.Value; } if (a.Key.Equals("serverPort", StringComparison.OrdinalIgnoreCase)) { serverPort = a.Value; } if (a.Key.Equals("serverUserId", StringComparison.OrdinalIgnoreCase)) { serverUserId = a.Value; } if (a.Key.Equals("serverPassword", StringComparison.OrdinalIgnoreCase)) { serverPassword = a.Value; } if (a.Key.Equals("serverAliasName", StringComparison.OrdinalIgnoreCase)) { serverAliasName = a.Value; } if (a.Key.Equals("regionNo", StringComparison.OrdinalIgnoreCase)) { regionNo = a.Value; } if (a.Key.Equals("zoneNo", StringComparison.OrdinalIgnoreCase)) { zoneNo = a.Value; } if (a.Key.Equals("serverImageProductCode", StringComparison.OrdinalIgnoreCase)) { serverImageProductCode = a.Value; } if (a.Key.Equals("serverProductCode", StringComparison.OrdinalIgnoreCase)) { serverProductCode = a.Value; } if (a.Key.Equals("feeSystemTypeCode", StringComparison.OrdinalIgnoreCase)) { feeSystemTypeCode = a.Value; } if (a.Key.Equals("loginKeyName", StringComparison.OrdinalIgnoreCase)) { loginKeyName = a.Value; } if (a.Key.Equals("accessControlGroupConfigurationNoList_1", StringComparison.OrdinalIgnoreCase)) { accessControlGroupConfigurationNoList_1 = a.Value; } if (a.Key.Equals("accessControlGroupConfigurationNoList_2", StringComparison.OrdinalIgnoreCase)) { accessControlGroupConfigurationNoList_2 = a.Value; } if (a.Key.Equals("accessControlGroupConfigurationNoList_3", StringComparison.OrdinalIgnoreCase)) { accessControlGroupConfigurationNoList_3 = a.Value; } if (a.Key.Equals("accessControlGroupConfigurationNoList_4", StringComparison.OrdinalIgnoreCase)) { accessControlGroupConfigurationNoList_4 = a.Value; } if (a.Key.Equals("accessControlGroupConfigurationNoList_5", StringComparison.OrdinalIgnoreCase)) { accessControlGroupConfigurationNoList_5 = a.Value; } } TBL_SERVER.Insert( new TBL_SERVER_KEY { serverName = serverName }, new TBL_SERVER_VALUE { serverInstanceNo = serverInstanceNo, serverPublicIp = serverPublicIp, serverPrivateIp = serverPrivateIp, serverPort = serverPort, serverUserId = serverUserId, serverPassword = serverPassword, serverAliasName = serverAliasName, regionNo = regionNo, zoneNo = zoneNo, serverImageProductCode = serverImageProductCode, serverProductCode = serverProductCode, feeSystemTypeCode = feeSystemTypeCode, loginKeyName = loginKeyName, accessControlGroupConfigurationNoList_1 = accessControlGroupConfigurationNoList_1, accessControlGroupConfigurationNoList_2 = accessControlGroupConfigurationNoList_2, accessControlGroupConfigurationNoList_3 = accessControlGroupConfigurationNoList_3, accessControlGroupConfigurationNoList_4 = accessControlGroupConfigurationNoList_4, accessControlGroupConfigurationNoList_5 = accessControlGroupConfigurationNoList_5 }); json = TBL_SERVER.GetJson(); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + tableName.ToString() + ".txt"), json); break; case TableName.TBL_CLUSTER_SERVER: foreach (var a in parameters) { if (a.Key.Equals("clusterName", StringComparison.OrdinalIgnoreCase)) { clusterName = a.Value; } if (a.Key.Equals("serverName", StringComparison.OrdinalIgnoreCase)) { serverName = a.Value; } if (a.Key.Equals("serverRole", StringComparison.OrdinalIgnoreCase)) { serverRole = a.Value; } } TBL_CLUSTER_SERVER.Insert( new TBL_CLUSTER_SERVER_KEY { clusterName = clusterName, serverName = serverName }, new TBL_CLUSTER_SERVER_VALUE { serverRole = serverRole }); json = TBL_CLUSTER_SERVER.GetJson(); File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory + tableName.ToString() + ".txt"), json); break; default: throw new ArgumentOutOfRangeException("unknown table"); } await UploadFileToObject(tableName); }
/// <summary> /// Provides an oppurtunity for derived implementations to also update the schema /// </summary> /// <param name="tableName"></param> protected override string AdditionalSchemaModifications(TableName tableName) { var receiveIndexName = $"IDX_RECEIVE_LEASE_{tableName.Schema}_{tableName.Name}"; var deleteIndexName = $"IDX_DELETE_LEASE_{tableName.Schema}_{tableName.Name}"; return($@" IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{tableName.Schema}' AND TABLE_NAME = '{tableName.Name}' AND COLUMN_NAME = 'leaseduntil') BEGIN ALTER TABLE {tableName.QualifiedName} ADD leaseduntil datetime2 null END ---- IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{tableName.Schema}' AND TABLE_NAME = '{tableName.Name}' AND COLUMN_NAME = 'leasedby') BEGIN ALTER TABLE {tableName.QualifiedName} ADD leasedby nvarchar({LeasedByColumnSize}) null END ---- IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{tableName.Schema}' AND TABLE_NAME = '{tableName.Name}' AND COLUMN_NAME = 'leasedat') BEGIN ALTER TABLE {tableName.QualifiedName} ADD leasedat datetime2 null END ---- -- Drop the V0 Receive Index -- v0 index was (Priority, Visible, Expiration, LeasedUntil, Id) -- We can find this by looking for the index with priority as is_descending_key = 0 IF EXISTS (SELECT 1 FROM sys.indexes I JOIN sys.index_columns IC ON I.object_id = OBJECT_ID('{tableName.QualifiedName}') AND I.name = '{receiveIndexName}' AND IC.object_id = I.object_id AND IC.index_id = I.index_id JOIN sys.columns C ON C.object_id = IC.object_id AND C.column_id = IC.column_id AND C.name = 'priority' and IC.is_descending_key = 0) BEGIN DROP INDEX [{receiveIndexName}] ON {tableName.QualifiedName} END ---- -- V1 Index: (Priority DESC, Visible, Id, Expiration, LeasedUntil) IF NOT EXISTS (SELECT 1 FROM sys.indexes I JOIN sys.objects O ON I.name = '{receiveIndexName}' AND I.object_id = o.object_id and o.schema_id = SCHEMA_ID('{tableName.Schema}')) BEGIN CREATE NONCLUSTERED INDEX [{receiveIndexName}] ON {tableName.QualifiedName} ( [priority] DESC, [visible] ASC, [id] ASC, [expiration] ASC, [leaseduntil] ASC ) END ---- IF NOT EXISTS (SELECT 1 FROM sys.indexes I JOIN sys.objects O ON I.name = '{deleteIndexName}' AND I.object_id = o.object_id and o.schema_id = SCHEMA_ID('{tableName.Schema}')) BEGIN CREATE NONCLUSTERED INDEX [{deleteIndexName}] ON {tableName.QualifiedName} ( [id] ASC ) END "); }
void InnerEnsureTableIsCreated(TableName table) { using (var connection = _connectionProvider.GetConnection()) { var tableNames = connection.GetTableNames(); if (tableNames.Contains(table)) { // Use the current database prefix if one is not provided var schema = table.Schema; if (string.IsNullOrWhiteSpace(schema)) { schema = connection.Database; } var tableName = table.Name; // Check if the schema needs to be upgraded var columns = connection.GetColumns(schema, tableName); if (!columns.ContainsKey("processing") && columns.ContainsKey("ordering_key") && columns.ContainsKey("leased_until") && columns.ContainsKey("leased_by") && columns.ContainsKey("leased_for") && columns.ContainsKey("leased_at")) { _log.Info("Database already contains a table named {tableName} - will not create anything", table.QualifiedName); } else { connection.ExecuteCommands($@" {MySqlMagic.DropColumnIfExistsSql(schema, tableName, "processing")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "ordering_key", $"varchar({OrderingKeyColumnSize}) NULL after `visible`")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_until", "datetime(6) NULL after `body`")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_by", $"varchar({LeasedByColumnSize}) NULL after `leased_until`")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_for", $"varchar({OrderingKeyColumnSize}) NULL after `leased_by`")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_at", "datetime(6) NULL after `leased_for`")} ---- {MySqlMagic.DropIndexIfExistsSql(schema, tableName, "idx_receive")} ---- {MySqlMagic.DropIndexIfExistsSql(schema, tableName, "idx_receive_lease")} ---- {MySqlMagic.CreateIndexIfNotExistsSql(schema, tableName, "idx_receive", "`priority` DESC, `visible` ASC, `id` ASC, `expiration` ASC, `leased_until` DESC, `leased_for` ASC")} ---- {MySqlMagic.CreateIndexIfNotExistsSql(schema, tableName, "idx_leased_for", "`leased_for`")}"); } } else { _log.Info("Table {tableName} does not exist - it will be created now", table.QualifiedName); connection.ExecuteCommands($@" CREATE TABLE {table.QualifiedName} ( `id` BIGINT NOT NULL AUTO_INCREMENT, `priority` INT NOT NULL, `expiration` DATETIME(6) NOT NULL, `visible` DATETIME(6) NOT NULL, `ordering_key` varchar({OrderingKeyColumnSize}) NULL, `headers` LONGBLOB NOT NULL, `body` LONGBLOB NOT NULL, `leased_until` datetime(6) NULL, `leased_by` varchar({LeasedByColumnSize}) NULL, `leased_for` varchar({OrderingKeyColumnSize}) NULL, `leased_at` datetime(6) NULL, PRIMARY KEY (`id`) ); ---- CREATE INDEX `idx_receive` ON {table.QualifiedName} ( `priority` DESC, `visible` ASC, `id` ASC, `expiration` ASC, `leased_until` DESC, `leased_for` ASC ); ---- CREATE INDEX `idx_leased_for` ON {table.QualifiedName} ( `leased_for` ); ---- CREATE INDEX `idx_expiration` ON {table.QualifiedName} ( `expiration` );"); } connection.Complete(); } }
public static DataTable StorageSchema(this TableName tableName) { string SQL = string.Format("Exec sp_spaceused N'{0}'", tableName.ShortName); return(Use(tableName, SQL)); }
/// <summary> /// Provides an opportunity for derived implementations to also update the schema /// </summary> /// <param name="connection">Connection to the database</param> /// <param name="table">Name of the table to create schema modifications for</param> protected override void AdditionalSchemaModifications(IDbConnection connection, TableName table) { // Use the current database prefix if one is not provided var schema = table.Schema; if (string.IsNullOrWhiteSpace(schema)) { schema = connection.Database; } var tableName = table.Name; // If any of our columns do not exist, run the schema upgrade var columns = connection.GetColumns(schema, tableName); var indexes = connection.GetIndexes(schema, tableName); if (!columns.ContainsKey("leased_until") || !columns.ContainsKey("leased_by") || !columns.ContainsKey("leased_at") || !indexes.ContainsKey("idx_receive_lease")) { connection.ExecuteCommands($@" {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_until", "datetime(6) null")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_by", $"varchar({LeasedByColumnSize}) null")} ---- {MySqlMagic.CreateColumnIfNotExistsSql(schema, tableName, "leased_at", "datetime(6) null")} ---- {MySqlMagic.DropIndexIfExistsSql(schema, tableName, "idx_receive")} ---- {MySqlMagic.CreateIndexIfNotExistsSql(schema, tableName, "idx_receive_lease", "visible, expiration, processing, leased_until")}"); } }
/// <summary> /// Constructor /// </summary> /// <param name="connectionFactory"></param> /// <param name="tableName"></param> public SqlServerOutboxStorage(Func <Task <DbConnection> > connectionFactory, string tableName) { _connectionFactory = connectionFactory; _tableName = TableName.Parse(tableName); }
public override int GetHashCode() { return(TableName.GetHashCode() + Index.GetHashCode() + Name.GetHashCode()); }
/// <summary> /// Perform update table with data from an anonymous object /// </summary> /// <typeparam name="T"></typeparam> /// <param name="db"></param> /// <param name="valuesToUpdate"></param> /// <param name="tableName"></param> /// <returns></returns> public static IBuildAnonymousUpdate UpdateFrom <T>(this DbConnection db, T valuesToUpdate, TableName tableName) where T : class { tableName.MustNotBeNull(); var options = new HelperOptions(db.GetPocoInfo <T>()); options.TableName = tableName; var executor = new CustomSqlExecutor(db); var updater = new UpdateTableBuilder <T>(executor, db.GetExpressionSqlGenerator(), db.Provider(), options); updater.SetUpdates(valuesToUpdate); return(new UpdateAnonymousBuilder <T>(updater)); }
public UpdateTableStatisticsCommand(TableName table) { Table = table; }