本文整理汇总了C#中Table.FindColumn方法的典型用法代码示例。如果您正苦于以下问题:C# Table.FindColumn方法的具体用法?C# Table.FindColumn怎么用?C# Table.FindColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table.FindColumn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildDataDictionary
private static Dictionary<Column, object> BuildDataDictionary(AdoAdapter adapter,
IDictionary<string, object> data, Table table)
{
Func<string, bool> columnFilter = key =>
table.HasColumn(key) &&
(table.FindColumn(key).IsWriteable ||
((adapter.AdoOptions != null && adapter.AdoOptions.IdentityInsert) && table.FindColumn(key).IsIdentity));
return data.Where(kvp => columnFilter(kvp.Key))
.ToDictionary(kvp => table.FindColumn(kvp.Key), kvp => kvp.Value);
}
示例2: GetCommand
public ICommandBuilder GetCommand(Table table, params object[] keyValues)
{
_commandBuilder.Append(GetSelectClause(table));
var param = _commandBuilder.AddParameter(keyValues[0], table.FindColumn(table.PrimaryKey[0]));
_commandBuilder.Append(string.Format(" where {0} = {1}", _schema.QuoteObjectName(table.PrimaryKey[0]), param.Name));
for (int i = 1; i < table.PrimaryKey.Length; i++)
{
param = _commandBuilder.AddParameter(keyValues[i], table.FindColumn(table.PrimaryKey[i]));
_commandBuilder.Append(string.Format(" and {0} = {1}", _schema.QuoteObjectName(table.PrimaryKey[i]), param.Name));
}
return _commandBuilder;
}
示例3: GetDbDataParameter
private static IDbDataParameter GetDbDataParameter(Table table, IDbCommand command, KeyValuePair<string, object> kvp)
{
return command.Parameters.Cast<IDbDataParameter>().
FirstOrDefault
(p =>
p.SourceColumn ==
table.FindColumn(kvp.Key).ActualName);
}
示例4: CreateWhereInStatement
private string CreateWhereInStatement(SimpleExpression criteria, Table table)
{
var inClauseBuilder = new CommandBuilder(_schema);
var keyColumn = table.FindColumn(table.PrimaryKey[0]);
inClauseBuilder.Append(string.Format("SELECT {0} FROM {1}",
keyColumn.QualifiedName, table.QualifiedName));
inClauseBuilder.Append(" ");
inClauseBuilder.Append(string.Join(" ",
new Joiner(JoinType.Inner, _schema).GetJoinClauses(
new ObjectName(table.Schema, table.ActualName), criteria)));
inClauseBuilder.Append(" where ");
inClauseBuilder.Append(_expressionFormatter.Format(criteria));
return string.Format("{0} IN ({1})", keyColumn.QualifiedName, inClauseBuilder.Text);
}
示例5: BuildDataDictionary
private static Dictionary<Column, object> BuildDataDictionary(AdoAdapter adapter, IDictionary<string, object> data, Table table)
{
Func<string, bool> columnFilter;
if (adapter.AdoOptions != null && adapter.AdoOptions.IdentityInsert)
{
columnFilter =
key =>
{
Column column;
if (table.TryFindColumn(key, out column))
{
return column.IsWriteable || column.IsIdentity;
}
return false;
};
}
else
{
columnFilter = key => table.HasColumn(key) && table.FindColumn(key).IsWriteable;
}
var dataDictionary = data.Where(kvp => columnFilter(kvp.Key))
.ToDictionary(kvp => table.FindColumn(kvp.Key), kvp => kvp.Value);
return dataDictionary;
}
示例6: CreateColumnUpdateClause
private string CreateColumnUpdateClause(string columnName, object value, Table table)
{
var column = table.FindColumn(columnName);
return string.Format("{0} = {1}", column.QuotedName, _commandBuilder.AddParameter(value, column).Name);
}
示例7: GetUpdateClause
private string GetUpdateClause(Table table, IEnumerable<KeyValuePair<string, object>> data)
{
var setClause = string.Join(", ",
data.Where(kvp => table.HasColumn(kvp.Key) && table.FindColumn(kvp.Key).IsWriteable)
.Select(kvp => CreateColumnUpdateClause(kvp.Key, kvp.Value, table)));
return string.Format("update {0} set {1}", table.QualifiedName, setClause);
}
示例8: CreateColumnUpdateClause
private string CreateColumnUpdateClause(string columnName, object value, Table table)
{
var column = table.FindColumn(columnName);
var mathReference = value as SimpleReference;
string rightOperand;
if (ReferenceEquals(mathReference, null))
{
rightOperand = _commandBuilder.AddParameter(value, column).Name;
}
else
{
rightOperand =
new SimpleReferenceFormatter(_schema, _commandBuilder).FormatColumnClauseWithoutAlias(mathReference);
}
return string.Format("{0} = {1}", column.QuotedName, rightOperand);
}
示例9: InsertRow
private static IDictionary<string, object> InsertRow(IDictionary<string, object> row, List<Column> columns, Table table, IDbCommand insertCommand, IDbCommand selectCommand)
{
var values = new object[insertCommand.Parameters.Count];
foreach (var kvp in row)
{
int index = columns.IndexOf(table.FindColumn(kvp.Key));
if (index == -1)
{
values[index] = kvp.Value;
}
}
CommandHelper.SetParameterValues(insertCommand, values);
if (TryExecute(insertCommand) == 1)
return TryExecuteSingletonQuery(selectCommand);
return null;
}