本文整理汇总了C#中Microsoft.SqlServer.Server.SmiTypedGetterSetter.GetTypedGetterSetter方法的典型用法代码示例。如果您正苦于以下问题:C# SmiTypedGetterSetter.GetTypedGetterSetter方法的具体用法?C# SmiTypedGetterSetter.GetTypedGetterSetter怎么用?C# SmiTypedGetterSetter.GetTypedGetterSetter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.SqlServer.Server.SmiTypedGetterSetter
的用法示例。
在下文中一共展示了SmiTypedGetterSetter.GetTypedGetterSetter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetIEnumerableOfSqlDataRecord_Unchecked
private static void SetIEnumerableOfSqlDataRecord_Unchecked(
SmiEventSink_Default sink,
SmiTypedGetterSetter setters,
int ordinal,
SmiMetaData metaData,
IEnumerable<SqlDataRecord> value,
ParameterPeekAheadValue peekAhead
) {
// Get target gettersetter
setters = setters.GetTypedGetterSetter(sink, ordinal);
sink.ProcessMessagesAndThrow();
IEnumerator<SqlDataRecord> enumerator = null;
try {
// Need to copy field metadata to an array to call FillCompatibleITypeSettersFromRecord
SmiExtendedMetaData[] mdFields = new SmiExtendedMetaData[metaData.FieldMetaData.Count];
metaData.FieldMetaData.CopyTo(mdFields, 0);
SmiDefaultFieldsProperty defaults = (SmiDefaultFieldsProperty) metaData.ExtendedProperties[SmiPropertySelector.DefaultFields];
int recordNumber = 1; // used only for reporting position when there are errors.
// obtain enumerator and handle any peekahead values
if (null != peekAhead && null != peekAhead.FirstRecord) {
// hook up to enumerator
enumerator = peekAhead.Enumerator;
// send the first record that was obtained earlier
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
FillCompatibleSettersFromRecord(sink, setters, mdFields, peekAhead.FirstRecord, defaults);
recordNumber++;
}
else {
enumerator = value.GetEnumerator();
}
using (enumerator) {
while(enumerator.MoveNext()) {
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
SqlDataRecord record = enumerator.Current;
if (record.FieldCount != mdFields.Length) {
throw SQL.EnumeratedRecordFieldCountChanged(recordNumber);
}
for(int i=0; i<record.FieldCount; i++) {
if (!MetaDataUtilsSmi.IsCompatible(metaData.FieldMetaData[i], record.GetSqlMetaData(i))) {
throw SQL.EnumeratedRecordMetaDataChanged(record.GetName(i), recordNumber);
}
}
FillCompatibleSettersFromRecord(sink, setters, mdFields, record, defaults);
recordNumber++;
}
setters.EndElements(sink);
sink.ProcessMessagesAndThrow();
}
}
finally {
// Clean up!
IDisposable disposable = enumerator as IDisposable;
if (null != disposable) {
disposable.Dispose();
}
}
}
示例2: SetDbDataReader_Unchecked
// Set a DbDataReader to a Structured+MultiValued setter (table type)
// Assumes metaData correctly describes the reader's shape, and consumes only the current resultset
private static void SetDbDataReader_Unchecked(
SmiEventSink_Default sink,
SmiTypedGetterSetter setters,
int ordinal,
SmiMetaData metaData,
DbDataReader value
) {
// Get the target gettersetter
setters = setters.GetTypedGetterSetter(sink, ordinal);
sink.ProcessMessagesAndThrow();
// Iterate over all rows in the current set of results
while (value.Read()) {
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
FillCompatibleSettersFromReader(sink, setters, metaData.FieldMetaData, value);
}
setters.EndElements(sink);
sink.ProcessMessagesAndThrow();
}
示例3: SetIEnumerableOfSqlDataRecord_Unchecked
private static void SetIEnumerableOfSqlDataRecord_Unchecked(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, SmiMetaData metaData, IEnumerable<SqlDataRecord> value, ParameterPeekAheadValue peekAhead)
{
setters = setters.GetTypedGetterSetter(sink, ordinal);
sink.ProcessMessagesAndThrow();
IEnumerator<SqlDataRecord> enumerator = null;
try
{
SmiExtendedMetaData[] array = new SmiExtendedMetaData[metaData.FieldMetaData.Count];
metaData.FieldMetaData.CopyTo(array, 0);
SmiDefaultFieldsProperty useDefaultValues = (SmiDefaultFieldsProperty) metaData.ExtendedProperties[SmiPropertySelector.DefaultFields];
int recordNumber = 1;
if ((peekAhead != null) && (peekAhead.FirstRecord != null))
{
enumerator = peekAhead.Enumerator;
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
FillCompatibleSettersFromRecord(sink, setters, array, peekAhead.FirstRecord, useDefaultValues);
recordNumber++;
}
else
{
enumerator = value.GetEnumerator();
}
using (enumerator)
{
while (enumerator.MoveNext())
{
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
SqlDataRecord current = enumerator.Current;
if (current.FieldCount != array.Length)
{
throw SQL.EnumeratedRecordFieldCountChanged(recordNumber);
}
for (int i = 0; i < current.FieldCount; i++)
{
if (!MetaDataUtilsSmi.IsCompatible(metaData.FieldMetaData[i], current.GetSqlMetaData(i)))
{
throw SQL.EnumeratedRecordMetaDataChanged(current.GetName(i), recordNumber);
}
}
FillCompatibleSettersFromRecord(sink, setters, array, current, useDefaultValues);
recordNumber++;
}
setters.EndElements(sink);
sink.ProcessMessagesAndThrow();
}
}
finally
{
IDisposable disposable = enumerator;
if (disposable != null)
{
disposable.Dispose();
}
}
}
示例4: SetDataTable_Unchecked
private static void SetDataTable_Unchecked(
SmiEventSink_Default sink,
SmiTypedGetterSetter setters,
int ordinal,
SmiMetaData metaData,
DataTable value
) {
// Get the target gettersetter
setters = setters.GetTypedGetterSetter(sink, ordinal);
sink.ProcessMessagesAndThrow();
// iterate over all records
// if first record was obtained earlier, use it prior to pulling more
ExtendedClrTypeCode[] cellTypes = new ExtendedClrTypeCode[metaData.FieldMetaData.Count];
for(int i=0; i<metaData.FieldMetaData.Count; i++) {
cellTypes[i] = ExtendedClrTypeCode.Invalid;
}
foreach(DataRow row in value.Rows) {
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
// Set all columns in the record
for(int i=0; i<metaData.FieldMetaData.Count; i++) {
SmiMetaData fieldMetaData = metaData.FieldMetaData[i];
if (row.IsNull(i)) {
SetDBNull_Unchecked(sink, setters, i);
}
else {
object cellValue = row[i];
// Only determine cell types for first row, to save expensive
if (ExtendedClrTypeCode.Invalid == cellTypes[i]) {
cellTypes[i] = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(
fieldMetaData.SqlDbType, fieldMetaData.IsMultiValued, cellValue, fieldMetaData.Type,
//
SmiContextFactory.KatmaiVersion
);
}
SetCompatibleValueV200(sink, setters, i, fieldMetaData, cellValue, cellTypes[i], 0, NoLengthLimit, null);
}
}
}
setters.EndElements(sink);
sink.ProcessMessagesAndThrow();
}
示例5: SetDataTable_Unchecked
private static void SetDataTable_Unchecked(SmiEventSink_Default sink, SmiTypedGetterSetter setters, int ordinal, SmiMetaData metaData, DataTable value)
{
setters = setters.GetTypedGetterSetter(sink, ordinal);
sink.ProcessMessagesAndThrow();
ExtendedClrTypeCode[] codeArray = new ExtendedClrTypeCode[metaData.FieldMetaData.Count];
for (int i = 0; i < metaData.FieldMetaData.Count; i++)
{
codeArray[i] = ExtendedClrTypeCode.Invalid;
}
foreach (DataRow row in value.Rows)
{
setters.NewElement(sink);
sink.ProcessMessagesAndThrow();
for (int j = 0; j < metaData.FieldMetaData.Count; j++)
{
SmiMetaData data = metaData.FieldMetaData[j];
if (row.IsNull(j))
{
SetDBNull_Unchecked(sink, setters, j);
}
else
{
object obj2 = row[j];
if (ExtendedClrTypeCode.Invalid == codeArray[j])
{
codeArray[j] = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(data.SqlDbType, data.IsMultiValued, obj2, data.Type, 210L);
}
SetCompatibleValueV200(sink, setters, j, data, obj2, codeArray[j], 0, -1, null);
}
}
}
setters.EndElements(sink);
sink.ProcessMessagesAndThrow();
}