本文整理汇总了C#中Fields.GetList方法的典型用法代码示例。如果您正苦于以下问题:C# Fields.GetList方法的具体用法?C# Fields.GetList怎么用?C# Fields.GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fields
的用法示例。
在下文中一共展示了Fields.GetList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteInserts
//.........这里部分代码省略.........
// We need only track autoinc translations when field is referenced by foreign keys
if (fldLookup.AutoIncrement & fldLookup.ForeignKeys.Count > 0)
{
// Create a new hashtable to hold autoinc translations
fldLookup.AutoIncrementTranslations = new Hashtable();
// Create a new autoinc field to hold source value
fldAutoInc = new Field(tblSource.Fields, fld.Name, fldLookup.Type);
fldAutoInc.AutoIncrementTranslations = fldLookup.AutoIncrementTranslations;
break;
}
}
}
}
// See if this table is a candidate for bulk inserts
if (m_attemptBulkInsert | m_forceBulkInsert)
{
//var _with3 = ToTable.Parent.Parent;
Schema parentSchema = ToTable.Parent.Parent;
// We only attempt a bulk insert if the destination data source type is Sql Server and we are inserting
// fields into a table that has no auto-incs with foreign key dependencies (or user forces procedure)
UseBulkInsert = m_forceBulkInsert | (parentSchema.DataSourceType == DatabaseType.SqlServer & (fldAutoInc == null | colTables.Count == 1));
if (UseBulkInsert)
{
ParseBulkInsertSettings(ref FieldTerminator, ref RowTerminator);
if (m_bulkInsertFilePath.Substring(m_bulkInsertFilePath.Length - 1) != "\\")
m_bulkInsertFilePath += "\\";
BulkInsertFile = m_bulkInsertFilePath + (new Guid()).ToString() + ".tmp";
fsBulkInsert = File.Create(BulkInsertFile);
}
}
string selectString = "SELECT " + colFields.GetList() + " FROM " + FromTable.FullName;
bool skipKeyValuePreservation = false;
// Handle special case of self-referencing table
if (tblSource.IsReferencedBy(tblSource))
{
// We need a special order-by for this scenario to make sure referenced rows are inserted before other rows - this also
// means no auto-inc preservation is possible on this table
skipKeyValuePreservation = true;
selectString += " ORDER BY ";
int index = 0;
foreach (Field field in tblSource.Fields)
{
foreach (ForeignKeyField foreignKey in field.ForeignKeys)
{
if (string.Compare(tblSource.Name, foreignKey.ForeignKey.Table.Name, true) == 0)
{
selectString += (index > 0 ? ", " : "") + foreignKey.ForeignKey.Name;
index++;
}
}
}
}
else
{
// Order by auto increment field to help preserve the original value while transfering data to destination table
if (fldAutoInc != null)
selectString += " ORDER BY " + fldAutoInc.Name;
}
// Execute source query
示例2: ExecuteInserts
/// <summary>
/// Execute a command to insert or update data from source to destination table
/// </summary>
/// <param name="fromTable">Source table</param>
/// <param name="toTable">Destination table</param>
private void ExecuteInserts(Table fromTable, Table toTable)
{
Table sourceTable = (m_useFromSchemaRI ? fromTable : toTable);
Field autoIncField = null;
Field lookupField;
Field commonField;
bool usingIdentityInsert;
// Progress process variables
int progressIndex = 0;
int progressTotal;
// Bulk insert variables
bool useBulkInsert = false;
string bulkInsertFile = "";
string fieldTerminator = "";
string rowTerminator = "";
FileStream bulkInsertFileStream = null;
// Create a field list of all of the common fields in both tables
Fields fieldCollection = new Fields(toTable);
foreach (Field field in fromTable.Fields)
{
// Lookup field name in destination table
lookupField = toTable.Fields[field.Name];
if ((object)lookupField != null)
{
// We currently don't handle binary fields...
if (!(field.Type == OleDbType.Binary || field.Type == OleDbType.LongVarBinary || field.Type == OleDbType.VarBinary) & !(lookupField.Type == OleDbType.Binary || lookupField.Type == OleDbType.LongVarBinary || lookupField.Type == OleDbType.VarBinary))
{
// Copy field information from destination field
if (m_useFromSchemaRI)
{
commonField = new Field(fieldCollection, field.Name, field.Type);
commonField.AutoIncrement = field.AutoIncrement;
}
else
{
commonField = new Field(fieldCollection, lookupField.Name, lookupField.Type);
commonField.AutoIncrement = lookupField.AutoIncrement;
}
fieldCollection.Add(commonField);
}
}
}
// Exit if no common field names were found
if (fieldCollection.Count == 0)
{
m_overallProgress += fromTable.RowCount;
return;
}
progressTotal = fromTable.RowCount;
OnRowProgress(fromTable.Name, 0, progressTotal);
OnOverallProgress((int)m_overallProgress, (int)m_overallTotal);
// Setup to track to and from auto-inc values if table has an identity field
if (sourceTable.HasAutoIncField)
{
foreach (Field field in fieldCollection)
{
lookupField = sourceTable.Fields[field.Name];
if ((object)lookupField != null)
{
// We need only track auto inc translations when field is referenced by foreign keys
if (lookupField.AutoIncrement & lookupField.ForeignKeys.Count > 0)
{
// Create a new hash-table to hold auto-inc translations
lookupField.AutoIncrementTranslations = new Hashtable();
// Create a new auto-inc field to hold source value
autoIncField = new Field(toTable.Fields, field.Name, lookupField.Type);
autoIncField.AutoIncrementTranslations = lookupField.AutoIncrementTranslations;
break;
}
}
}
}
// See if this table is a candidate for bulk inserts
if (m_attemptBulkInsert || m_forceBulkInsert)
useBulkInsert = SetupBulkInsert(toTable, autoIncField, ref bulkInsertFile, ref fieldTerminator, ref rowTerminator, ref bulkInsertFileStream);
string selectString = "SELECT " + fieldCollection.GetList(sqlEscapeFunction: m_fromSchema.SQLEscapeName) + " FROM " + fromTable.SQLEscapedName;
bool skipKeyValuePreservation = false;
// Handle special case of self-referencing table
if (sourceTable.IsReferencedBy(sourceTable))
{
// We need a special order-by for this scenario to make sure referenced rows are inserted before other rows - this also
//.........这里部分代码省略.........