本文整理汇总了C#中Columns.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Columns.Add方法的具体用法?C# Columns.Add怎么用?C# Columns.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Columns
的用法示例。
在下文中一共展示了Columns.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColumns
private Columns GetColumns(string connectionString, string sqlCmd)
{
Columns columns = new Columns(50);
SqlDataReader dr = SqlHelper.ExecuteReader(connectionString, CommandType.Text, sqlCmd);
while (dr.Read())
{
string id = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
string displayName = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
string name = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
int length = dr.IsDBNull(3) ? 0 : dr.GetInt16(3);
bool identity = dr.IsDBNull(4) ? false : dr.GetBoolean(4);
bool isNullable = dr.IsDBNull(5) ? false : dr.GetBoolean(5);
bool isComputed = dr.IsDBNull(6) ? false : dr.GetBoolean(6);
string dataType = dr.IsDBNull(7) ? string.Empty : dr.GetString(7);
string comment = dr.IsDBNull(8) ? string.Empty : dr.GetString(8);
string defaultValue = dr.IsDBNull(9) ? string.Empty : dr.GetString(9);
Column column = new Column(id, displayName, name, dataType, comment);
column.Length = length;
column.IsAutoIncremented = identity;
column.IsNullable = isNullable;
column.DefaultValue = defaultValue;
column.DataType = dataType;
column.OriginalName = name;
column.IsComputed = isComputed;
columns.Add(id, column);
}
dr.Close();
return columns;
}
示例2: GetColumns
private Columns GetColumns(XmlNode tableOrViewNode)
{
XmlNode columnsNode = tableOrViewNode["c:Columns"];
if (columnsNode == null ||
columnsNode.ChildNodes.Count == 0) return null;
XmlNodeList columnNodes = columnsNode.ChildNodes;
Columns columns = new Columns(columnNodes.Count);
foreach (XmlNode columnNode in columnNodes)
{
string id = columnNode.Attributes["Id"].InnerText;
string displayName = columnNode["a:Name"].InnerText;
string name = columnNode["a:Code"].InnerText;
string comment = columnNode["a:Comment"] != null ? columnNode["a:Comment"].InnerText : string.Empty;
string dataType = columnNode["a:DataType"] != null ? columnNode["a:DataType"].InnerText : string.Empty;
string length = columnNode["a:Length"] != null ? columnNode["a:Length"].InnerText : "0";
string identity = columnNode["a:Identity"] != null ? columnNode["a:Identity"].InnerText : string.Empty;
string mandatory = columnNode["a:Mandatory"] != null ? columnNode["a:Mandatory"].InnerText : string.Empty;
string defaultValue = columnNode["a:DefaultValue"] != null ? columnNode["a:DefaultValue"].InnerText : string.Empty;
Column column = new Column(id, displayName, name, dataType, comment);
column.Length = Int32.Parse(length);
column.IsAutoIncremented = identity.Equals("1");
column.IsNullable = mandatory.Equals("1");
column.DefaultValue = defaultValue.ToEmpty();
column.DataType = Regex.Replace(column.DataType, "\\(.*?\\)", "");
column.OriginalName = name;
columns.Add(id, column);
}
return columns;
}
示例3: GetColumns
private Columns GetColumns(string connectionString, string sqlCmd)
{
Columns columns = new Columns(50);
MySqlDataReader dr = MySqlHelper.ExecuteReader(connectionString, sqlCmd);
while (dr.Read())
{
string id = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
string displayName = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
string name = dr.IsDBNull(2) ? string.Empty : dr.GetString(2);
string dataType = dr.IsDBNull(3) ? string.Empty : dr.GetString(3);
string key = dr.IsDBNull(4) ? string.Empty : dr.GetString(4);
string defaultValue = dr.IsDBNull(5) ? string.Empty : dr.GetString(5);
string isNullable = dr.IsDBNull(6) ? string.Empty : dr.GetString(6);
string length = dr.IsDBNull(7) ? string.Empty : dr.GetString(7);
string identity = dr.IsDBNull(8) ? string.Empty : dr.GetString(8);
string comment = dr.IsDBNull(9) ? string.Empty : dr.GetString(9);
Column column = new Column(id, displayName, name, dataType, comment);
column.Length = ConvertHelper.GetInt32(length);
column.IsAutoIncremented = identity.Equals("auto_increment");
column.IsNullable = isNullable.Equals("YES");
column.DefaultValue = defaultValue.ToEmpty();
column.DataType = dataType;
column.OriginalName = name;
columns.Add(id, column);
}
dr.Close();
return columns;
}
示例4: CalculateColumns
public Columns CalculateColumns()
{
Columns columns = new Columns();
Column lastColumn = null;
Offset lastOffset = Offset.Zero;
int count = _members.Count;
for (int i = 0; i < count; i++)
{
Offset thisOffset = this[i].TopOffset;
if (thisOffset.IsLessThanOrEqualTo(lastOffset))
{
if (lastColumn != null)
{
lastColumn.SetEnd(i);
}
Column col = new Column(this, i);
columns.Add(col);
lastColumn = col;
}
lastOffset = thisOffset;
}
lastColumn.SetEnd(count);
return columns;
}
示例5: Remove_Column
public void Remove_Column()
{
var test = new Columns();
var column = new Column("testing", ColumnTypes.Bigint, true);
test.Add(column);
test.Remove(column);
Assert.False(test.Items.Any(item => item.Name == "testing"));
}
示例6: AddGeneralColumn
public static GeneralColumn AddGeneralColumn(Columns Columns, TableField Field, bool IsEnabled, bool CanDisabled)
{
GeneralColumn Column = Columns.CreateGeneralColumn();
Column.Field = Field;
Column.IsEnabled = IsEnabled;
Column.CanDisable = CanDisabled;
Columns.Add(Column);
return Column;
}
示例7: GetPrimaryKeys
private Columns GetPrimaryKeys(int objectId, string connectionString, Columns columns)
{
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.Append("select syscolumns.name from syscolumns,sysobjects,sysindexes,sysindexkeys ");
sqlBuilder.AppendFormat("where syscolumns.id ={0} ", objectId);
sqlBuilder.Append("and sysobjects.xtype = 'PK' and sysobjects.parent_obj = syscolumns.id ");
sqlBuilder.Append("and sysindexes.id = syscolumns.id and sysobjects.name = sysindexes.name and ");
sqlBuilder.Append("sysindexkeys.id = syscolumns.id and sysindexkeys.indid = sysindexes.indid and syscolumns.colid = sysindexkeys.colid");
Columns primaryKeys = new Columns(4);
SqlDataReader dr = SqlHelper.ExecuteReader(connectionString, CommandType.Text, sqlBuilder.ToString());
while (dr.Read())
{
string name = dr.IsDBNull(0) ? string.Empty : dr.GetString(0);
if (columns.ContainsKey(name)) primaryKeys.Add(name, columns[name]);
}
dr.Close();
return primaryKeys;
}
示例8: Script
public void Script()
{
var test = new Columns();
test.Add(new Column("testing", ColumnTypes.Bigint, true));
Assert.Contains("testing", test.Script());
}
示例9: Add_Column
public void Add_Column()
{
var test = new Columns();
test.Add(new Column("testing", ColumnTypes.Bigint, true));
Assert.True(test.Items.Any(item => item.Name == "testing"));
}
示例10: GetKeys
private Dictionary<string, Columns> GetKeys(XmlNode tableNode, Columns tableColumns)
{
XmlNode keysNode = tableNode["c:Keys"];
if (keysNode == null ||
keysNode.ChildNodes.Count == 0) return null;
Dictionary<string, Columns> keys = new Dictionary<string, Columns>(keysNode.ChildNodes.Count);
foreach (XmlNode keyNode in keysNode.ChildNodes)
{
string keyId = keyNode.Attributes["Id"].InnerText;
XmlNode keyColumnsNode = keyNode["c:Key.Columns"];
if (keyColumnsNode == null ||
keyColumnsNode.ChildNodes.Count == 0) return null;
Columns keyColumns = new Columns(keyColumnsNode.ChildNodes.Count);
foreach (XmlNode keyColumnNode in keyColumnsNode.ChildNodes)
{
string id = keyColumnNode.Attributes["Ref"].InnerText;
if (tableColumns.ContainsKey(id))
keyColumns.Add(id, tableColumns[id]);
}
keys.Add(keyId, keyColumns);
}
return keys;
}
示例11: GetColumns
/// <summary>
/// Setea las columbas y claves de una determinada tabla .-
/// </summary>
/// <param name="pColumnsDtt">DataTable con las columnas de una tabla obtenida de la base de datos</param>
/// <param name="pTableName">Nombre de la tabla.-</param>
/// <returns>Objeto Columns de la tabla.-</returns>
private Columns GetColumns(DataTable pColumnsDtt,string pTableName)
{
Columns wCampos = new Columns ();
DataTable wDttKeys = GetKeysFromTable(pTableName);
foreach(DataRow wDtrColumn in pColumnsDtt.Rows)
{
Column wCampo = new Column ();
wCampo.Name = wDtrColumn["col_name"].ToString ();
wCampo.IsIdentity = Convert.ToBoolean(wDtrColumn["col_identity"]);
wCampo.Length = Convert.ToInt32 ( wDtrColumn["col_len"]);
if (!wDtrColumn.IsNull("col_prec"))
wCampo.Prec = Convert.ToInt32(wDtrColumn["col_prec"]);
if (!wDtrColumn.IsNull("col_scale"))
wCampo.Scale = Convert.ToInt32(wDtrColumn["col_scale"]);
wCampo.Type = wDtrColumn["col_typename"].ToString ();
wCampo.Nullable = Convert.ToBoolean( wDtrColumn["col_null"]);
wCampo.Computed = wDtrColumn["col_iscomputed"].ToString ();
wCampo.KeyField = (wDttKeys.Select("COLUMN_NAME = '" + wCampo.Name + "'").Length > 0);
wCampo.Autogenerated = wCampo.IsIdentity;
wCampos.Add (wCampo);
}
return wCampos;
}
示例12: GetKeys
private Columns GetKeys(XmlNode tableNode, Columns tableColumns)
{
XmlNode keysNode = tableNode["c:Keys"];
if (keysNode == null ||
keysNode.ChildNodes.Count == 0) return null;
XmlNode keyColumnsNode = keysNode.ChildNodes[0]["c:Key.Columns"];
if (keyColumnsNode == null ||
keyColumnsNode.ChildNodes.Count == 0) return null;
XmlNodeList keyColumnNodes = keyColumnsNode.ChildNodes;
Columns keys = new Columns(keyColumnNodes.Count);
foreach (XmlNode keyColumnNode in keyColumnNodes)
{
string id = keyColumnNode.Attributes["Ref"].InnerText;
if (!tableColumns.ContainsKey(id)) continue;
keys.Add(id, tableColumns[id]);
}
return keys;
}
示例13: GetPrimaryKeys
private Columns GetPrimaryKeys(XmlNode tableNode, Columns tableColumns)
{
XmlNode xmlNode = tableNode["c:PrimaryKey"];
if (xmlNode == null ||
xmlNode.ChildNodes.Count == 0) return null;
XmlNodeList primaryKeyNodes = xmlNode.ChildNodes;
Columns primaryKeys = new Columns(primaryKeyNodes.Count);
foreach (XmlNode primaryKeyNode in primaryKeyNodes)
{
string id = primaryKeyNode.Attributes["Ref"].InnerText;
if (!tableColumns.ContainsKey(id)) continue;
primaryKeys.Add(id,tableColumns[id]);
}
return primaryKeys;
}
示例14: PrepareData
private void PrepareData()
{
MapInfo.Data.Table mdbTable = MapInfo.Engine.Session.Current.Catalog[SampleConstants.EWorldAlias];
MapInfo.Data.Table worldTable = MapInfo.Engine.Session.Current.Catalog[SampleConstants.ThemeTableAlias];
// worldTable is loaded by preloaded mapinfo workspace file specified in web.config.
// and MS Access table in this sample is loaded manually.
// we are not going to re-load it again once it got loaded because its content is not going to change in this sample.
// we will get performance gain if we use Pooled MapInfo Session.
// Note: It's better to put this MS Access table into pre-loaded workspace file,
// so we don't need to do below code.
// We manually load this MS Access in this sample for demonstration purpose.
if(mdbTable == null)
{
System.Web.HttpServerUtility util = HttpContext.Current.Server;
string dataPath = util.MapPath(string.Format("/ThematicsWebCS_{0}_{1}", MapInfo.Engine.ProductInfo.MajorVersion, MapInfo.Engine.ProductInfo.MinorVersion));
mdbTable = MapInfo.Engine.Session.Current.Catalog.OpenTable(System.IO.Path.Combine(dataPath, SampleConstants.EWorldTabFileName));
string[] colAlias = SampleConstants.BoundDataColumns;
// DateBinding columns
Column col0 = MapInfo.Data.ColumnFactory.CreateDoubleColumn(colAlias[0]);
col0.ColumnExpression = mdbTable.Alias + "." + colAlias[0];
Column col1 = MapInfo.Data.ColumnFactory.CreateIntColumn(colAlias[1]);
col1.ColumnExpression = mdbTable.Alias + "." + colAlias[1];
Column col2 = MapInfo.Data.ColumnFactory.CreateIntColumn(colAlias[2]);
col2.ColumnExpression = mdbTable.Alias + "." + colAlias[2];
Columns cols = new Columns();
cols.Add(col0);
cols.Add(col1);
cols.Add(col2);
// Databind MS Access table data to existing worldTable.
worldTable.AddColumns(cols, BindType.DynamicCopy, mdbTable, SampleConstants.SouceMatchColumn, Operator.Equal, SampleConstants.TableMatchColumn);
}
}
示例15: AsColumns
/// <summary>
/// 将数据库字段元数据集合转换为字段元数据集合类型。
/// </summary>
/// <param name="columns">字段元数据集合</param>
/// <returns>字段元数据集合类型</returns>
public static Columns AsColumns(this IEnumerable<Column> columns)
{
var result = new Columns();
return result.Add(columns);
}