本文整理汇总了C#中TableInfo类的典型用法代码示例。如果您正苦于以下问题:C# TableInfo类的具体用法?C# TableInfo怎么用?C# TableInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableInfo类属于命名空间,在下文中一共展示了TableInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TableQueryInfo
public TableQueryInfo(IUserSession session, TableInfo tableInfo, ObjectName tableName, ObjectName aliasName)
{
Session = session;
TableInfo = tableInfo;
TableName = tableName;
AliasName = aliasName;
}
示例2: SessionTableContainer
static SessionTableContainer()
{
// SYSTEM.OPEN_SESSIONS
OpenSessionsTableInfo = new TableInfo(SystemSchema.OpenSessionsTableName);
OpenSessionsTableInfo.AddColumn("username", PrimitiveTypes.String());
OpenSessionsTableInfo.AddColumn("host_string", PrimitiveTypes.String());
OpenSessionsTableInfo.AddColumn("last_command", PrimitiveTypes.DateTime());
OpenSessionsTableInfo.AddColumn("time_connected", PrimitiveTypes.DateTime());
OpenSessionsTableInfo = OpenSessionsTableInfo.AsReadOnly();
// SYSTEM.SESSION_INFO
SessionInfoTableInfo = new TableInfo(SystemSchema.SessionInfoTableName);
SessionInfoTableInfo.AddColumn("var", PrimitiveTypes.String());
SessionInfoTableInfo.AddColumn("value", PrimitiveTypes.String());
SessionInfoTableInfo = SessionInfoTableInfo.AsReadOnly();
// SYSTEM.STATS
StatisticsTableInfo = new TableInfo(SystemSchema.StatisticsTableName);
StatisticsTableInfo.AddColumn("stat_name", PrimitiveTypes.String());
StatisticsTableInfo.AddColumn("value", PrimitiveTypes.String());
StatisticsTableInfo = StatisticsTableInfo.AsReadOnly();
IntTableInfo = new TableInfo[3];
IntTableInfo[0] = StatisticsTableInfo;
IntTableInfo[1] = SessionInfoTableInfo;
IntTableInfo[2] = OpenSessionsTableInfo;
}
示例3: Create
public void Create()
{
// SYSTEM.ROUTINE
var tableInfo = new TableInfo(SystemSchema.RoutineTableName);
tableInfo.AddColumn("schema", PrimitiveTypes.String());
tableInfo.AddColumn("name", PrimitiveTypes.String());
tableInfo.AddColumn("type", PrimitiveTypes.String());
tableInfo.AddColumn("location", PrimitiveTypes.String());
tableInfo.AddColumn("return_type", PrimitiveTypes.String());
tableInfo.AddColumn("username", PrimitiveTypes.String());
transaction.CreateTable(tableInfo);
// SYSTEM.ROUTINE_PARAM
tableInfo = new TableInfo(SystemSchema.RoutineParameterTableName);
tableInfo.AddColumn("schema", PrimitiveTypes.String());
tableInfo.AddColumn("name", PrimitiveTypes.String());
tableInfo.AddColumn("arg_name", PrimitiveTypes.String());
tableInfo.AddColumn("arg_type", PrimitiveTypes.String());
tableInfo.AddColumn("in_out", PrimitiveTypes.String());
tableInfo.AddColumn("offset", PrimitiveTypes.Integer());
transaction.CreateTable(tableInfo);
var fkCol = new[] {"routine_schema", "routine_name"};
var refCol = new[] {"schema", "name"};
const ForeignKeyAction onUpdate = ForeignKeyAction.NoAction;
const ForeignKeyAction onDelete = ForeignKeyAction.Cascade;
transaction.AddForeignKey(SystemSchema.RoutineParameterTableName, fkCol, SystemSchema.RoutineTableName, refCol,
onDelete, onUpdate, "ROUTINE_PARAMS_FK");
}
示例4: GetAutoIncrementExpression
public override string GetAutoIncrementExpression(TableInfo ti)
{
if (!string.IsNullOrEmpty(ti.SequenceName))
return string.Format("{0}.nextval", ti.SequenceName);
return null;
}
示例5: TestSetup
public void TestSetup()
{
var tableInfo = new TableInfo(ObjectName.Parse("APP.people"));
tableInfo.AddColumn("id", PrimitiveTypes.Bit());
tableInfo.AddColumn("first_name", PrimitiveTypes.String(), true);
tableInfo.AddColumn("last_name", PrimitiveTypes.String());
tableInfo.AddColumn("age", PrimitiveTypes.TinyInt());
table = new TemporaryTable(tableInfo);
var tempTable = (TemporaryTable) table;
tempTable.NewRow(new[] {
DataObject.BigInt(1),
DataObject.String("Antonello"),
DataObject.String("Provenzano"),
DataObject.Null()
});
tempTable.NewRow(new[] {
DataObject.BigInt(2),
DataObject.String("Moritz"),
DataObject.String("Krull"),
DataObject.TinyInt(31)
});
tempTable.BuildIndexes();
}
示例6: CreateAdminSession
protected override ISession CreateAdminSession(IDatabase database)
{
using (var session = base.CreateAdminSession(database)) {
using (var query = session.CreateQuery()) {
var tn1 = ObjectName.Parse("APP.test_table1");
var tableInfo1 = new TableInfo(tn1);
tableInfo1.AddColumn(new ColumnInfo("id", PrimitiveTypes.Integer()));
tableInfo1.AddColumn(new ColumnInfo("name", PrimitiveTypes.String()));
tableInfo1.AddColumn(new ColumnInfo("date", PrimitiveTypes.DateTime()));
query.CreateTable(tableInfo1);
query.AddPrimaryKey(tn1, "id");
var tn2 = ObjectName.Parse("APP.test_table2");
var tableInfo2 = new TableInfo(tn2);
tableInfo2.AddColumn(new ColumnInfo("id", PrimitiveTypes.Integer()));
tableInfo2.AddColumn(new ColumnInfo("other_id", PrimitiveTypes.Integer()));
tableInfo2.AddColumn(new ColumnInfo("count", PrimitiveTypes.Integer()));
query.CreateTable(tableInfo2);
query.AddPrimaryKey(tn2, "id");
query.AddForeignKey(tn2, new[] { "other_id" }, tn1, new[] { "id" }, ForeignKeyAction.Cascade, ForeignKeyAction.Cascade, null);
query.Commit();
}
}
return base.CreateAdminSession(database);
}
示例7: DoRun
protected override void DoRun()
{
var tables = Connection.GetSchema("Tables");
var columns = new List<DataRow>();
foreach (DataRow row in Connection.GetSchema("Columns").Rows) columns.Add(row);
columns = new List<DataRow>(columns.SortedByKey<DataRow, int>(c => c.SafeInt("ORDINAL_POSITION")));
foreach (DataRow row in tables.Rows)
{
if (row.SafeString("TABLE_TYPE") != "BASE TABLE") continue;
var table = new TableInfo(Result);
table.FullName = new NameWithSchema(row.SafeString("TABLE_SCHEMA"), row.SafeString("TABLE_NAME"));
Result.Tables.Add(table);
_tables[table.FullName] = table;
}
foreach (DataRow row in columns)
{
if (row.SafeString("TABLE_TYPE") != "BASE TABLE") continue;
var tname = new NameWithSchema(row.SafeString("TABLE_SCHEMA"), row.SafeString("TABLE_NAME"));
var table = _tables[tname];
var col = new ColumnInfo(table);
col.Name = row.SafeString("COLUMN_NAME");
col.NotNull = row.SafeString("IS_NULLABLE") == "NO";
col.DataType = row.SafeString("DATA_TYPE");
col.Length = row.SafeInt("CHARACTER_MAXIMUM_LENGTH");
col.Precision = row.SafeInt("NUMERIC_PRECISION");
col.Scale = row.SafeInt("NUMERIC_SCALE");
col.DefaultValue = row.SafeString("COLUMN_DEFAULT");
table.Columns.Add(col);
}
}
示例8: CreateSimpleTableAsAdmin
public void CreateSimpleTableAsAdmin()
{
var tableName = ObjectName.Parse("APP.test_table");
var tableInfo = new TableInfo(tableName);
tableInfo.AddColumn("a", PrimitiveTypes.Integer(), true);
tableInfo.AddColumn("b", PrimitiveTypes.String());
using (var session = Database.CreateUserSession(AdminUserName, AdminPassword)) {
using (var context = new SessionQueryContext(session)) {
Assert.DoesNotThrow(() => {
context.CreateTable(tableInfo);
});
}
Assert.DoesNotThrow(() => session.Commit());
}
using (var session = Database.CreateUserSession(AdminUserName, AdminPassword)) {
using (var context = new SessionQueryContext(session)) {
bool exists = false;
Assert.DoesNotThrow(() => exists = context.TableExists(tableName));
Assert.IsTrue(exists);
}
}
}
示例9: GetTableInfo
internal static TableInfo GetTableInfo( Type t )
{
TableInfo table;
if ( _tableNameCache.TryGetValue( t, out table ) ) return table;
table = new TableInfo();
table.TableName = t.Name;
table.SchemaName = "dbo";
// check for an attribute specifying something different
var tableAttribute = t.GetCustomAttribute<TableAttribute>( false );
if ( tableAttribute != null )
{
table.TableName = tableAttribute.Name;
if ( !string.IsNullOrWhiteSpace( tableAttribute.Schema ) ) table.SchemaName = tableAttribute.Schema;
}
// get the property names that can be mapped
foreach ( var pi in t.GetProperties( System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public ).Where( m => m.CanRead && m.CanWrite && !m.HasCustomAttribute<NotMappedAttribute>( false ) ) )
table.FieldNames.Add( GetFieldName( pi ) );
// get the key property names
foreach ( var pi in t.GetProperties( System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public ).Where( m => m.CanRead && m.CanWrite && m.HasCustomAttribute<System.ComponentModel.DataAnnotations.KeyAttribute>( false ) ) )
table.PrimaryKeyFieldNames.Add( GetFieldName( pi ) );
// try to add the newly aquired info
if ( _tableNameCache.TryAdd( t, table ) ) return table;
return _tableNameCache[ t ];
}
示例10: CreateObjectInfo
public IObjectInfo CreateObjectInfo(Type forType)
{
if (forType == null)
{
throw new ArgumentNullException("forType");
}
var tableAttribute = forType.GetAttribute<TableAttribute>(inherit: false);
if (tableAttribute == null)
{
throw new MappingException(ExceptionMessages.AttributeMappingConvention_NoTableAttribute.FormatWith(forType.FullName));
}
var identifierStrategy = IdentifierStrategy.DbGenerated;
var columns = this.CreateColumnInfos(forType, ref identifierStrategy);
var tableInfo = new TableInfo(columns, identifierStrategy, tableAttribute.Name, tableAttribute.Schema);
if (this.log.IsDebug)
{
this.log.Debug(LogMessages.MappingConvention_MappingTypeToTable, forType.FullName, tableInfo.Schema, tableInfo.Name);
}
return new PocoObjectInfo(forType, tableInfo);
}
示例11: GetDeleteByIdSql
public static string GetDeleteByIdSql(TableInfo tableInfo)
{
string strSql = "delete from {0} where {1} =" + AdoHelper.DbParmChar + tableInfo.Id.Key;
strSql = string.Format(strSql, tableInfo.TableName, tableInfo.Id.Key);
return strSql;
}
示例12: CreateTable
private void CreateTable(IQuery query)
{
var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
tableInfo.AddColumn("a", PrimitiveTypes.Integer());
tableInfo.AddColumn("b", PrimitiveTypes.String(), false);
query.CreateTable(tableInfo, false, false);
}
示例13: OnSetUp
protected override bool OnSetUp(string testName, IQuery query)
{
var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
tableInfo.AddColumn("a", PrimitiveTypes.Integer());
query.Access().CreateObject(tableInfo);
return true;
}
示例14: TableInfoListViewItem
public TableInfoListViewItem(TableInfo table)
{
this.Table = table;
if (table == null) return;
this.Name = table.Name;
this.Text = $"{table.Name} ({table.TotalRecords})";
}
示例15: IsTableDropped
private bool IsTableDropped(IEnumerable<RelationalModelChange> changes, TableInfo table)
{
return CollectionUtils.Contains(changes,
delegate(RelationalModelChange c)
{
return c is DropTableChange && Equals(c.Table, table);
});
}