当前位置: 首页>>代码示例>>C#>>正文


C# SqlParameter.MetaDataForSmi方法代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlParameter.MetaDataForSmi方法的典型用法代码示例。如果您正苦于以下问题:C# SqlParameter.MetaDataForSmi方法的具体用法?C# SqlParameter.MetaDataForSmi怎么用?C# SqlParameter.MetaDataForSmi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.SqlParameter的用法示例。


在下文中一共展示了SqlParameter.MetaDataForSmi方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteSmiParameter

        private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj)
        {
            //
            // Determine Metadata
            //
            ParameterPeekAheadValue peekAhead;
            MSS.SmiParameterMetaData metaData = param.MetaDataForSmi(out peekAhead);

            if (!_isKatmai)
            {
                MetaType mt = MetaType.GetMetaTypeFromSqlDbType(metaData.SqlDbType, metaData.IsMultiValued);
                throw ADP.VersionDoesNotSupportDataType(mt.TypeName);
            }

            //
            //  Determine value to send
            //
            object value;
            MSS.ExtendedClrTypeCode typeCode;

            // if we have an output or default param, set the value to null so we do not send it across to the server
            if (sendDefault)
            {
                // Value for TVP default is empty list, not NULL
                if (SqlDbType.Structured == metaData.SqlDbType && metaData.IsMultiValued)
                {
                    value = s_tvpEmptyValue;
                    typeCode = MSS.ExtendedClrTypeCode.IEnumerableOfSqlDataRecord;
                }
                else
                {
                    // Need to send null value for default
                    value = null;
                    typeCode = MSS.ExtendedClrTypeCode.DBNull;
                }
            }
            else if (param.Direction == ParameterDirection.Output)
            {
                bool isCLRType = param.ParamaterIsSqlType;  // We have to forward the TYPE info, we need to know what type we are returning.  Once we null the paramater we will no longer be able to distinguish what type were seeing.
                param.Value = null;
                value = null;
                typeCode = MSS.ExtendedClrTypeCode.DBNull;
                param.ParamaterIsSqlType = isCLRType;
            }
            else
            {
                value = param.GetCoercedValue();
                typeCode = MSS.MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(metaData.SqlDbType, metaData.IsMultiValued, value);
            }


            //
            // Write parameter metadata
            //
            WriteSmiParameterMetaData(metaData, sendDefault, stateObj);

            //
            // Now write the value
            //
            TdsParameterSetter paramSetter = new TdsParameterSetter(stateObj, metaData);
            MSS.ValueUtilsSmi.SetCompatibleValueV200(
                                        new MSS.SmiEventSink_Default(),  // TDS Errors/events dealt with at lower level for now, just need an object for processing
                                        paramSetter,
                                        0,          // ordinal.  TdsParameterSetter only handles one parameter at a time
                                        metaData,
                                        value,
                                        typeCode,
                                        param.Offset,
                                        0 < param.Size ? param.Size : -1,
                                        peekAhead);
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:71,代码来源:TdsParser.cs

示例2: WriteSmiParameter

 private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefault, TdsParserStateObject stateObj)
 {
     object coercedValue;
     ExtendedClrTypeCode iEnumerableOfSqlDataRecord;
     ParameterPeekAheadValue value2;
     SmiParameterMetaData metaData = param.MetaDataForSmi(out value2);
     if (!this._isKatmai)
     {
         throw ADP.VersionDoesNotSupportDataType(MetaType.GetMetaTypeFromSqlDbType(metaData.SqlDbType, metaData.IsMultiValued).TypeName);
     }
     if (sendDefault)
     {
         if ((SqlDbType.Structured == metaData.SqlDbType) && metaData.IsMultiValued)
         {
             coercedValue = __tvpEmptyValue;
             iEnumerableOfSqlDataRecord = ExtendedClrTypeCode.IEnumerableOfSqlDataRecord;
         }
         else
         {
             coercedValue = null;
             iEnumerableOfSqlDataRecord = ExtendedClrTypeCode.DBNull;
         }
     }
     else if (param.Direction == ParameterDirection.Output)
     {
         bool paramaterIsSqlType = param.ParamaterIsSqlType;
         param.Value = null;
         coercedValue = null;
         iEnumerableOfSqlDataRecord = ExtendedClrTypeCode.DBNull;
         param.ParamaterIsSqlType = paramaterIsSqlType;
     }
     else
     {
         coercedValue = param.GetCoercedValue();
         iEnumerableOfSqlDataRecord = MetaDataUtilsSmi.DetermineExtendedTypeCodeForUseWithSqlDbType(metaData.SqlDbType, metaData.IsMultiValued, coercedValue, null, 210L);
     }
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<sc.TdsParser.WriteSmiParameter|ADV> %d#, Sending parameter '%ls', default flag=%d, metadata:\n", this.ObjectID, param.ParameterName, sendDefault ? 1 : 0);
         Bid.PutStr(metaData.TraceString(3));
         Bid.Trace("\n");
     }
     this.WriteSmiParameterMetaData(metaData, sendDefault, stateObj);
     TdsParameterSetter setters = new TdsParameterSetter(stateObj, metaData);
     ValueUtilsSmi.SetCompatibleValueV200(new SmiEventSink_Default(), setters, 0, metaData, coercedValue, iEnumerableOfSqlDataRecord, param.Offset, (0 < param.Size) ? param.Size : -1, value2);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:TdsParser.cs


注:本文中的System.Data.SqlClient.SqlParameter.MetaDataForSmi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。