本文整理汇总了C#中Fields.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Fields.Add方法的具体用法?C# Fields.Add怎么用?C# Fields.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fields
的用法示例。
在下文中一共展示了Fields.Add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fields
public Fields Fields() {
var fields = new Fields();
foreach (var join in Join) {
fields.Add(join.Fields());
}
return fields;
}
示例2: Read
public Fields Read(AbstractConnection connection, string process, string prefix, string name, string schema, bool isMaster = false) {
var fields = new Fields();
using (var cn = connection.GetConnection()) {
cn.Open();
var sql = PrepareSql();
connection.Logger.EntityDebug(name, sql);
var results = cn.Query(sql, new { name, schema });
foreach (var result in results) {
var columnName = result.COLUMN_NAME;
var type = GetSystemType(result.DATA_TYPE);
var length = result.CHARACTER_MAXIMUM_LENGTH == "0" || result.CHARACTER_MAXIMUM_LENGTH == "-1" ? "64" : result.CHARACTER_MAXIMUM_LENGTH;
var fieldType = (bool)result.IS_PRIMARY_KEY ? (isMaster ? FieldType.MasterKey : FieldType.PrimaryKey) : FieldType.NonKey;
var field = new Field(type, length, fieldType, true, string.Empty) {
Name = columnName,
Entity = name,
Process = process,
Index = Convert.ToInt16(result.ORDINAL_POSITION - 1),
Schema = schema,
Input = true,
Precision = result.NUMERIC_PRECISION,
Scale = result.NUMERIC_SCALE,
Alias = prefix + columnName
};
fields.Add(field);
}
}
return fields;
}
示例3: LuceneKeysExtractAll
public LuceneKeysExtractAll(LuceneConnection luceneConnection, Entity entity, bool input = false) {
_luceneConnection = luceneConnection;
_entity = entity;
_input = input;
_fields = entity.PrimaryKey;
if (entity.Version != null && !_fields.HaveField(entity.Version.Alias)) {
_fields.Add(entity.Version);
}
_selected = _fields.Select(f => input ? f.Name : f.Alias).ToArray();
}
示例4: GetRelationshipFields
protected Fields GetRelationshipFields(IEnumerable<Relationship> rel, Entity entity) {
var relationships = rel.Where(r => r.LeftEntity.Alias != entity.Alias && r.RightEntity.Alias != entity.Alias).ToArray();
var fields = new Fields();
if (relationships.Any()) {
foreach (var relationship in relationships) {
var leftSide = relationship.LeftEntity.RelationshipToMaster.Count();
var rightSide = relationship.RightEntity.RelationshipToMaster.Count();
if (leftSide <= rightSide) {
foreach (var join in relationship.Join) {
fields.Add(join.LeftField);
}
} else {
foreach (var join in relationship.Join) {
fields.Add(join.RightField);
}
}
}
}
return fields;
}
示例5: Read
public Fields Read(string name, string schema) {
var result = new Fields();
using (var cn = _connection.GetConnection()) {
cn.Open();
var cmd = cn.CreateCommand();
cmd.CommandText = string.Format("select * from {0}{1} where 1=2;", schema.Equals(string.Empty) ? string.Empty : _connection.Enclose(schema) + ".", _connection.Enclose(name));
var reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly);
var table = reader.GetSchemaTable();
if (table != null) {
var keys = table.PrimaryKey.Any() ? table.PrimaryKey.Select(c => c.ColumnName).ToArray() : Enumerable.Empty<string>().ToArray();
foreach (DataRow row in table.Rows) {
var columnName = row["ColumnName"].ToString();
var field = new Field(keys.Contains(columnName) ? FieldType.PrimaryKey : FieldType.NonKey) {
Name = columnName,
Type = Common.ToSimpleType(row["DataType"].ToString())
};
if (field.Type.Equals("string")) {
field.Length = row["ColumnSize"].ToString();
} else {
field.Precision = Convert.ToInt32(row["NumericPrecision"]);
field.Scale = Convert.ToInt32(row["NumericScale"]);
}
if (Convert.ToBoolean(row["IsRowVersion"])) {
field.Length = "8";
field.Type = "rowversion";
}
result.Add(field);
}
}
};
return result;
}
示例6: SearchFields
public Fields SearchFields() {
var fields = new Fields();
foreach (var pair in new StarFields(this).TypedFields()) {
fields.Add(pair.Value.WithSearchType());
}
return fields;
}
示例7: Fields
public Fields Fields() {
var fields = new Fields();
foreach (var entity in Entities) {
fields.Add(entity.Fields);
fields.Add(entity.CalculatedFields);
}
fields.Add(CalculatedFields);
return fields;
}
示例8: Field
public Field(Fields fields, String sequence)
{
this.sequence = sequence;
fields.Add(this);
}
示例9: 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)
{
Fields colFields = default(Fields);
//Field fld = default(Field);
Field fldLookup = null;
Field fldCommon = null;
string InsertSqlStub = null;
StringBuilder InsertSql = null;
string UpdateSqlStub = null;
StringBuilder UpdateSql = null;
string CountSqlStub = null;
StringBuilder CountSql = null;
StringBuilder WhereSql = null;
string strValue = null;
bool AddedFirstInsert = false;
bool AddedFirstUpdate = false;
bool IsPrimary = false;
//Dim flgRecordExists As Boolean
int ProgressIndex = 0;
int Total = 0;
Table tblSource = (flgUseFromSchemaRI ? FromTable : ToTable);
Field fldAutoInc = null;
bool UseBulkInsert = false;
StringBuilder BulkInsertRow = null;
string BulkInsertFile = "";
string FieldTerminator = "";
string RowTerminator = "";
FileStream fsBulkInsert = null;
byte[] bytDataRow = null;
// Create a field list of all of the common fields in both tables
colFields = new Fields(ToTable);
foreach (Field fld in FromTable.Fields)
{
// Lookup field name in destination table
fldLookup = ToTable.Fields[fld.Name];
if (fldLookup != null)
{
//var _with1 = fldLookup;
// We currently don't handle binary fields...
if (!(fld.Type == OleDbType.Binary | fld.Type == OleDbType.LongVarBinary | fld.Type == OleDbType.VarBinary) & !(fldLookup.Type == OleDbType.Binary | fldLookup.Type == OleDbType.LongVarBinary | fldLookup.Type == OleDbType.VarBinary))
{
// Copy field information from destination field
if (flgUseFromSchemaRI)
{
fldCommon = new Field(colFields, fld.Name, fld.Type);
fldCommon.AutoIncrement = fld.AutoIncrement;
}
else
{
fldCommon = new Field(colFields, fldLookup.Name, fldLookup.Type);
fldCommon.AutoIncrement = fldLookup.AutoIncrement;
}
colFields.Add(fldCommon);
}
}
}
// Exit if no common field names were found
if (colFields.Count == 0)
{
intOverallProgress += FromTable.RowCount;
return;
}
Total = FromTable.RowCount;
RaiseEvent_RowProgress(FromTable.Name, 0, Total);
RaiseEvent_OverallProgress((int)intOverallProgress, (int)intOverallTotal);
// Setup to track to and from autoinc values if table has an identity field
if (tblSource.HasAutoIncField)
{
foreach (Field fld in colFields)
{
fldLookup = tblSource.Fields[fld.Name];
if ((fldLookup != null))
{
//var _with2 = fldLookup;
// 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;
}
}
}
}
//.........这里部分代码省略.........
示例10: InitialFieldTypes
public Fields InitialFieldTypes() {
var fields = new Fields();
var delimiter = FindDelimiter();
if (_storage.Count == 0) {
_logger.EntityWarn(_fileInfo.Name, "No lines in file.");
return fields;
}
var firstLine = _storage[0];
if (delimiter == default(char)) {
var field = new Field("string", _request.DefaultLength, FieldType.NonKey, true, string.Empty) {
Name = firstLine.Content
};
fields.Add(field);
return fields;
}
var names = firstLine.Values[delimiter].Select(n=>n.Trim(firstLine.Quote)).ToArray();
for (var i = 0; i < names.Length; i++) {
var name = names[i];
var field = new Field(_request.DefaultType, _request.DefaultLength, FieldType.NonKey, true, string.Empty) {
Name = name,
QuotedWith = firstLine.Quote
};
fields.Add(field);
}
return fields;
}
示例11: GetEntitySchema
public override Fields GetEntitySchema(Process process, Entity entity, bool isMaster = false) {
var fields = new Fields();
var solr = GetReadonlyOperations(process, entity.OutputName());
var solrSchema = solr.GetSchema(_schemaFile);
foreach (var solrField in solrSchema.SolrFields) {
string type;
var searchType = "default";
if (SolrTypeMap.ContainsKey(solrField.Type.Name)) {
type = SolrTypeMap[solrField.Type.Name];
searchType = solrField.Type.Name;
} else {
type = solrField.Type.Name;
}
var field = new Field(type, "64", FieldType.None, true, string.Empty) {
Name = solrField.Name,
Entity = entity.Name,
Input = solrField.IsStored,
SearchTypes = new List<SearchType>() { new SearchType() { Name = searchType, Analyzer = searchType } }
};
fields.Add(field);
}
return fields;
}
示例12: 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
//.........这里部分代码省略.........
示例13: GetEntitySchema
public override Fields GetEntitySchema(Process process, Entity entity, bool isMaster = false) {
var client = new ElasticSearchClientFactory().CreateNest(this, entity);
var mapping = client.Client.GetMapping<dynamic>(m => m
.Index(client.Index)
.Type(client.Type)
);
if (!mapping.IsValid) {
throw new TransformalizeException(Logger, "Trouble getting mapping for {0}:{1} {2}", client.Index, client.Type, mapping.ServerError.Error);
}
var fields = new Fields();
foreach (var pair in mapping.Mapping.Properties) {
fields.Add(new Field(pair.Value.Type.Name, "64", FieldType.None, true, "") { Name = pair.Key.Name });
}
return fields;
}
示例14: ProcessNode
private void ProcessNode(XmlNode xmlNode, Fields fields)
{
if (xmlNode.NodeType != XmlNodeType.Text)
{
foreach (XmlNode xmlNestedNode in xmlNode.ChildNodes)
{
ProcessNode(xmlNestedNode, fields);
}
}
else
{
fields.Add(xmlNode.ParentNode.Name, xmlNode.InnerText);
}
}