本文整理汇总了C#中System.Data.SqlClient.SqlDataReader.GetColumnLookup方法的典型用法代码示例。如果您正苦于以下问题:C# SqlDataReader.GetColumnLookup方法的具体用法?C# SqlDataReader.GetColumnLookup怎么用?C# SqlDataReader.GetColumnLookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataReader
的用法示例。
在下文中一共展示了SqlDataReader.GetColumnLookup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getProcedures
private IEnumerable<SPInfo> getProcedures(SqlDataReader reader)
{
var index = reader.GetColumnLookup();
foreach (var r in reader)
{
var id = reader.GetInt32(index["ID"]);
var name = reader.GetString(index["Name"]);
var schema = reader.GetString(index["Schema"]);
var dateCreated = reader.GetDateTime(index["Created"]);
var dateModified = reader.GetDateTime(index["Modified"]);
var sp = new SPInfo(id, name, schema, dateCreated, dateModified);
yield return sp;
}
}
示例2: getParameters
private IEnumerable<Tuple<int, SPParameter>> getParameters(SqlDataReader reader)
{
var index = reader.GetColumnLookup();
foreach (var r in reader)
{
var procId = reader.GetInt32(index["ProcedureId"]);
var typeName = reader.GetString(index["t.name"]);
var maxLength = reader.GetInt16(index["t.maxLen"]);
var precision = reader.GetByte(index["t.precision"]);
var scale = reader.GetByte(index["t.scale"]);
var typeInfo = new DbTypeInfo(typeName, null, maxLength, precision, scale);
var name = reader.GetString(index["Name"]);
var position = reader.GetInt32(index["position"]);
var isOutput = reader.GetBoolean(index["output"]);
var isReadOnly = reader.GetBoolean(index["readonly"]);
var defaultValue = reader.GetValue(index["defaultValue"]);
var param = new SPParameter(name, typeInfo, position, isOutput, isReadOnly, defaultValue);
yield return Tuple.Create(procId, param);
}
}