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


C# DbCommand.GetType方法代码示例

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


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

示例1: CacheOracleDbTypeEnumValues

 protected virtual void CacheOracleDbTypeEnumValues(DbCommand command) {
     var assembly = command.GetType().GetTypeInfo().Assembly;
     var typeEnum = assembly.GetType(OracleDbTypeEnumName);
     ReflectionCache.DbTypeRefCursor = Enum.Parse(typeEnum, "RefCursor");
     ReflectionCache.DbTypeBlob = Enum.Parse(typeEnum, "Blob");
     ReflectionCache.DbTypeDate = Enum.Parse(typeEnum, "Date");
 }
开发者ID:SharpTools,项目名称:sharpdata,代码行数:7,代码来源:OracleOdpProvider.cs

示例2: EnsureOracleBindByName

 private static void EnsureOracleBindByName(DbCommand cmd)
 {
     //Oracle.DataAccess.Client only binds first parameter match unless BindByName=true
     //so we violate LiskovSP (in reflection to avoid dependency on ODP)
     if (cmd.GetType().GetProperty("BindByName") != null)
     {
         cmd.GetType().GetProperty("BindByName").SetValue(cmd, true, null);
     }
 }
开发者ID:shiningrise,项目名称:dbschemareader,代码行数:9,代码来源:OracleSchemaReader.cs

示例3: PrepareParameterScale

 static internal Exception PrepareParameterScale(DbCommand cmd, string type)
 {
     return InvalidOperation(Res.GetString(Res.ADP_PrepareParameterScale, cmd.GetType().Name, type));
 }
开发者ID:dotnet,项目名称:corefx,代码行数:4,代码来源:AdapterUtil.cs

示例4: Query

        public DataTable Query( DbCommand cmd )
        {
            if ( cmd == null )
            {
                throw new ArgumentNullException( "cmd" );
            }

            SQLiteCommand sqliteCmd = cmd as SQLiteCommand;
            if ( cmd == null )
            {
                throw new ArgumentException( "command has invalid type: " + cmd.GetType() );
            }

            Open( false );

            if ( sqliteCmd.Connection != myConnection )
            {
                sqliteCmd.Connection = myConnection;
            }

            // TODO: use:
            // DbDataReader reader = cmd.ExecuteReader();
            // table.Load( reader );

            SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter( sqliteCmd );

            DataTable table = new DataTable();
            table.Locale = CultureInfo.InvariantCulture;
            dataAdapter.Fill( table );

            return table;
        }
开发者ID:bg0jr,项目名称:Maui,代码行数:32,代码来源:SQLiteDatabaseSC.cs

示例5: DatabaseEngineIs

 protected virtual bool DatabaseEngineIs(DbCommand command, params System.String[] flavors)
 {
     return DatabaseEngineIs(command.GetType().FullName, flavors);
 }
开发者ID:mehedi09,项目名称:GridWork,代码行数:4,代码来源:Controller.Core.cs

示例6: GetParameterFormat

        /// <summary>
        /// Gets the format of the parameter, to avoid query the schema the parameter
        /// format is cached with the type of the parameter. This version is used 
        /// for the old interface of DataAccess based on anonimous function.
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        private static String GetParameterFormat(DbCommand command)
        {
            String typeName = command.GetType().FullName;
            if (!mParametersFormat.ContainsKey(typeName))
            {

                    mParametersFormat.Add(typeName,
                    command.Connection.GetSchema("DataSourceInformation")
                        .Rows[0]["ParameterMarkerFormat"].ToString());

            }
            return mParametersFormat[typeName];
        }
开发者ID:mbsky,项目名称:dotnetmarcheproject,代码行数:20,代码来源:DataAccess.cs

示例7: PrepareParameterSize

 internal static Exception PrepareParameterSize(DbCommand cmd)
 {
     return InvalidOperation(Res.GetString(Res.ADP_PrepareParameterSize, cmd.GetType().Name));
 }
开发者ID:chcosta,项目名称:corefx,代码行数:4,代码来源:AdapterUtil.cs

示例8: ConfigureCommandForSelect

 private void ConfigureCommandForSelect(DbCommand command, ViewPage page, SelectClauseDictionary expressions, string fromClause, string whereClause, string orderByClause, CommandConfigurationType commandConfiguration)
 {
     bool useServerPaging = ((commandConfiguration != CommandConfigurationType.SelectDistinct && !(_serverRules.EnableResultSet)) && (commandConfiguration != CommandConfigurationType.SelectAggregates && commandConfiguration != CommandConfigurationType.SelectFirstLetters));
     bool useLimit = SupportsLimitInSelect(command);
     bool useSkip = SupportsSkipInSelect(command);
     if (useServerPaging)
         page.AcceptAllRows();
     StringBuilder sb = new StringBuilder();
     if (useLimit || useSkip)
         useServerPaging = false;
     bool countUsingHierarchy = false;
     if ((commandConfiguration == CommandConfigurationType.SelectCount) && (useServerPaging && RequiresHierarchy(page)))
     {
         countUsingHierarchy = true;
         commandConfiguration = CommandConfigurationType.Select;
     }
     if (commandConfiguration == CommandConfigurationType.SelectExisting)
         useServerPaging = false;
     if (commandConfiguration == CommandConfigurationType.SelectCount)
         sb.AppendLine("select count(*)");
     else
     {
         if (useServerPaging)
             sb.AppendLine("with page_cte__ as (");
         else
             if ((commandConfiguration == CommandConfigurationType.Sync) && useLimit)
                 sb.Append("select * from (select @row_num := @row_num+1 row_number__,cte__.* from (select @r" +
                         "ow_num:=0) r,(");
         sb.AppendLine("select");
         if (useServerPaging)
             AppendRowNumberExpression(sb, page, expressions, orderByClause);
         if (commandConfiguration == CommandConfigurationType.SelectDistinct)
         {
             DataField distinctField = page.FindField(page.DistinctValueFieldName);
             string distinctExpression = expressions[distinctField.ExpressionName()];
             if (distinctField.Type.StartsWith("Date"))
             {
                 string commandType = command.GetType().ToString();
                 if (commandType == "System.Data.SqlClient.SqlCommand")
                     distinctExpression = String.Format("DATEADD(dd, 0, DATEDIFF(dd, 0, {0}))", distinctExpression);
                 if (commandType == "MySql.Data.MySqlClient.MySqlCommand")
                     distinctExpression = String.Format("cast({0} as date)", distinctExpression);
             }
             sb.AppendFormat("distinct {0} \"{1}\"\r\n", distinctExpression, page.DistinctValueFieldName);
         }
         else
             if (commandConfiguration == CommandConfigurationType.SelectAggregates)
                 AppendAggregateExpressions(sb, page, expressions);
             else
                 if (commandConfiguration == CommandConfigurationType.SelectFirstLetters)
                 {
                     string substringFunction = "substring";
                     if (DatabaseEngineIs(command, "Oracle", "DB2"))
                         substringFunction = "substr";
                     AppendFirstLetterExpressions(sb, page, expressions, substringFunction);
                 }
                 else
                 {
                     if ((commandConfiguration == CommandConfigurationType.Select) && useSkip)
                         sb.AppendFormat(" first {0} skip {1}\r\n", page.PageSize, (page.PageSize * page.PageIndex));
                     if ((commandConfiguration == CommandConfigurationType.Sync) && useSkip)
                     {
                         // Only select the primary key.
                         foreach (DataField field in page.Fields)
                             if (field.IsPrimaryKey)
                             {
                                 sb.Append(expressions[field.ExpressionName()]);
                                 break;
                             }
                     }
                     else
                         if (commandConfiguration == CommandConfigurationType.SelectExisting)
                             sb.AppendLine("*");
                         else
                             AppendSelectExpressions(sb, page, expressions, !(useServerPaging));
                 }
     }
     sb.AppendLine("from");
     sb.AppendLine(fromClause);
     _hasWhere = false;
     if (String.IsNullOrEmpty(_viewFilter))
     {
         _viewFilter = _view.GetAttribute("filter", String.Empty);
         if (String.IsNullOrEmpty(_viewFilter) && ((_viewType == "Form") && !(String.IsNullOrEmpty(page.LastView))))
         {
             XPathNavigator lastView = _config.SelectSingleNode("/c:dataController/c:views/c:view[@id=\'{0}\']", page.LastView);
             if (lastView != null)
                 _viewFilter = lastView.GetAttribute("filter", String.Empty);
         }
     }
     if (!(String.IsNullOrEmpty(_viewFilter)))
         _viewFilter = String.Format("({0})", _viewFilter);
     if (commandConfiguration == CommandConfigurationType.SelectExisting)
     {
         EnsureWhereKeyword(sb);
         sb.Append(expressions[page.InnerJoinForeignKey.ToLower()]);
         sb.Append("=");
         sb.Append(page.InnerJoinPrimaryKey);
         sb.AppendLine(" and ");
     }
//.........这里部分代码省略.........
开发者ID:mehedi09,项目名称:GridWork,代码行数:101,代码来源:Controller.cs

示例9: InitSetBindByName

 private static MethodInfo InitSetBindByName(DbCommand command)
 {
     return command.GetType().GetMethod("set_BindByName", BindingFlags.Public | BindingFlags.Instance);
 }
开发者ID:wrx362114,项目名称:ServiceStack.OrmLite,代码行数:4,代码来源:OracleCommand.cs

示例10: EscapePattern

 public static string EscapePattern(DbCommand command, string s)
 {
     if (String.IsNullOrEmpty(s))
         return s;
     if (command.GetType().FullName == "System.Data.SqlClient.SqlCommand")
         return _sqlClientPatternEscape.Replace(s, "[$1]");
     return s;
 }
开发者ID:mehedi09,项目名称:GridWork,代码行数:8,代码来源:DataAccess.cs

示例11: AddDbCommandStatements

		private void AddDbCommandStatements (CodeMemberMethod m, 
		                                     CodeExpression expr, 
		                                     DbCommand cmd)
		{
			if (cmd == null)
				return;
			
			CodeExpression expr1;
			CodeStatement stmt = Let (expr, New (cmd.GetType ()));
			m.Statements.Add (stmt);
			
			stmt = Let (PropRef (expr,"Connection"), PropRef ("Connection"));
			m.Statements.Add (stmt);
			stmt = Let (PropRef (expr, "CommandText"), Const (cmd.CommandText));
			m.Statements.Add (stmt);
			expr1 = PropRef (Local(typeof (CommandType).FullName), cmd.CommandType.ToString ());
			stmt = Let (PropRef (expr, "CommandType"), expr1);
			m.Statements.Add (stmt);
			
			expr1 = PropRef (expr, "Parameters");
			foreach (DbParameter param in cmd.Parameters) {
				AddDbParameterStatements (m, expr1, param);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:24,代码来源:CustomDataClassGenerator.cs

示例12: CreateDBCommandCollectionFieldAndProperty

		private void CreateDBCommandCollectionFieldAndProperty (CodeTypeDeclaration t, DbCommand cmd)
		{
			CodeExpression expr;
			CodeStatement setStmt;
			CodeStatement stmt;
			CodeMemberField f = new CodeMemberField ();
			f.Name = "_commandCollection";
			f.Type = TypeRefArray (cmd.GetType (), 1);
			t.Members.Add (f);
			
			CodeMemberProperty p = new CodeMemberProperty ();
			p.Name = "CommandCollection";
			p.Attributes = MemberAttributes.Family;
			p.Type = f.Type;
			p.HasSet = false;

			expr = FieldRef ("_commandCollection");
			setStmt = Eval (MethodInvoke ("InitCommandCollection"));
			stmt = new CodeConditionStatement (Equals (expr, Const (null)),
			                                   new CodeStatement [] {setStmt},
			                                   new CodeStatement [] {});
			p.GetStatements.Add (stmt);
			p.GetStatements.Add (Return (expr));
			t.Members.Add (p);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:CustomDataClassGenerator.cs

示例13: AppendFilterExpressionsToWhere


//.........这里部分代码省略.........
                                         {
                                             string exactFlag = "=";
                                             if (String.IsNullOrEmpty(m.Groups["Quote"].Value))
                                                 exactFlag = " ";
                                             string negativeFlag = " ";
                                             if (negativeSample)
                                             {
                                                 negativeFlag = "-";
                                                 negativeSample = false;
                                             }
                                             words.Add(String.Format("{0}{1}{2}", negativeFlag, exactFlag, m.Groups["Value"].Value));
                                         }
                                     m = m.NextMatch();
                                 }
                                 bool firstPhrase = true;
                                 foreach (List<String> phrase in phrases)
                                     if (phrase.Count > 0)
                                     {
                                         if (firstPhrase)
                                             firstPhrase = false;
                                         else
                                             sb.AppendLine("or");
                                         sb.AppendLine("(");
                                         bool firstWord = true;
                                         System.DateTime paramValueAsDate;
                                         foreach (string paramValueWord in phrase)
                                         {
                                             bool negativeFlag = (paramValueWord[0] == '-');
                                             bool exactFlag = (paramValueWord[1] == '=');
                                             string comparisonOperator = "like";
                                             if (exactFlag)
                                                 comparisonOperator = "=";
                                             string pv = paramValueWord.Substring(2);
                                             bool paramValueIsDate = SqlStatement.TryParseDate(command.GetType(), pv, out paramValueAsDate);
                                             bool firstTry = true;
                                             DbParameter parameter = null;
                                             if (!(paramValueIsDate))
                                                 pv = SqlStatement.EscapePattern(command, pv);
                                             double paramValueAsNumber;
                                             string testNumber = pv;
                                             foreach (string s in removableNumericCharacters)
                                                 testNumber = testNumber.Replace(s, string.Empty);
                                             bool paramValueIsNumber = double.TryParse(testNumber, out paramValueAsNumber);
                                             if (!(exactFlag) && !(pv.Contains("%")))
                                                 pv = String.Format("%{0}%", pv);
                                             if (firstWord)
                                                 firstWord = false;
                                             else
                                                 sb.Append("and");
                                             if (negativeFlag)
                                                 sb.Append(" not");
                                             sb.Append("(");
                                             bool hasTests = false;
                                             DbParameter originalParameter = null;
                                             if (String.IsNullOrEmpty(quickFindHint) || !(quickFindHint.StartsWith(";")))
                                                 foreach (DataField tf in page.Fields)
                                                     if ((tf.AllowQBE && String.IsNullOrEmpty(tf.AliasName)) && (!((tf.IsPrimaryKey && tf.Hidden)) && (!(tf.Type.StartsWith("Date")) || paramValueIsDate)))
                                                     {
                                                         hasTests = true;
                                                         if ((parameter == null) || command.GetType().FullName.Contains("ManagedDataAccess"))
                                                         {
                                                             parameter = command.CreateParameter();
                                                             parameter.ParameterName = String.Format("{0}p{1}", _parameterMarker, command.Parameters.Count);
                                                             parameter.DbType = DbType.String;
                                                             command.Parameters.Add(parameter);
                                                             parameter.Value = pv;
开发者ID:mehedi09,项目名称:GridWork,代码行数:67,代码来源:Controller.Filter.cs

示例14: CacheCommandProperties

 protected virtual void CacheCommandProperties(DbCommand command) {
     var oracleDbCommandType = command.GetType().GetTypeInfo();
     ReflectionCache.PropBindByName = oracleDbCommandType.GetDeclaredProperty("BindByName");
     ReflectionCache.PropArrayBindCount = oracleDbCommandType.GetDeclaredProperty("ArrayBindCount");
 }
开发者ID:SharpTools,项目名称:sharpdata,代码行数:5,代码来源:OracleOdpProvider.cs


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