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


C# DbParameter.Count方法代码示例

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


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

示例1: CallProcMethodGenerator

 public static string CallProcMethodGenerator(DbParameter[] dbParameter, string spname, int prefiexIndex, bool isPaging)
 {
     if (string.IsNullOrEmpty(spname))
     {
         throw new ArgumentNullException("spname");
     }
     if ((dbParameter == null) || (dbParameter.Length == 0))
     {
         if (((spname.IndexOf("get", StringComparison.OrdinalIgnoreCase) >= 0) || (spname.IndexOf("query", StringComparison.OrdinalIgnoreCase) >= 0)) || (spname.IndexOf("search", StringComparison.OrdinalIgnoreCase) >= 0))
         {
             return (string.Format("//TModel item = DbHelper.GetDataItem<TModel>(\"{0}\", null);\r\n", spname) + string.Format("List<TModel> list = DbHelper.FillList<TModel>(\"{0}\", null);\r\n", spname));
         }
         return string.Format("DbHelper.ExecuteNonQuery(\"{0}\", null);", spname);
     }
     bool flag = false;
     bool flag2 = false;
     bool flag3 = false;
     bool flag4 = false;
     foreach (DbParameter parameter in dbParameter)
     {
         if ((parameter.Direction == ParameterDirection.Output) || (parameter.Direction == ParameterDirection.InputOutput))
         {
             flag = true;
             if (string.Compare(parameter.ParameterName.Substring(prefiexIndex), DbContext.STR_TotalRecords, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 flag4 = true;
             }
         }
         else
         {
             if (string.Compare(parameter.ParameterName.Substring(prefiexIndex), DbContext.STR_PageIndex, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 flag2 = true;
             }
             if (string.Compare(parameter.ParameterName.Substring(prefiexIndex), DbContext.STR_PageSize, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 flag3 = true;
             }
         }
     }
     string str2 = spname.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Aggregate((i, j) =>
     {
         return i.Substring(0, 1).ToUpper() + i.Substring(1, i.Length - 1).ToLower()
             + j.Substring(0, 1).ToUpper() + j.Substring(1, j.Length - 1).ToLower();
     }).Replace(".", "");
     str2 = (isPaging || flag) ? (str2.FilterStr() + "Parameters") : string.Empty;
     StringBuilder builder = new StringBuilder();
     if (!string.IsNullOrEmpty(str2))
     {
         if ((flag2 && flag3) && flag4)
         {
             builder.Append("public class ").Append(str2).AppendLine(" : PagingInfo {");
             foreach (DbParameter parameter in dbParameter)
             {
                 if (parameter.DbType == DbType.Object)
                     continue;
                 if (((string.Compare(parameter.ParameterName.Substring(prefiexIndex), DbContext.STR_TotalRecords, StringComparison.OrdinalIgnoreCase) != 0) && (string.Compare(parameter.ParameterName.Substring(prefiexIndex), DbContext.STR_PageIndex, StringComparison.OrdinalIgnoreCase) != 0)) && (string.Compare(parameter.ParameterName.Substring(prefiexIndex), DbContext.STR_PageSize, StringComparison.OrdinalIgnoreCase) != 0))
                 {
                     builder.AppendFormat("\tpublic {0} {1} {{ get; set; }}\r\n", TypeConverter.ConvertToClrType(parameter.DbType), parameter.ParameterName.Substring(prefiexIndex));
                 }
             }
         }
         else
         {
             builder.Append("public class ").Append(str2).AppendLine(" {");
             foreach (DbParameter parameter in dbParameter)
             {
                 if (parameter.DbType == DbType.Object)
                     continue;
                 builder.AppendFormat("\tpublic {0} {1} {{ get; set; }}\r\n", TypeConverter.ConvertToClrType(parameter.DbType), parameter.ParameterName.Substring(prefiexIndex));
             }
         }
         builder.AppendLine("}\r\n");
     }
     builder.AppendFormat("var parameters = new {0}{{\r\n", str2);
     int num2 = 1;
     foreach (DbParameter parameter in dbParameter)
     {
         if (parameter.DbType == DbType.Object)
             continue;
         builder.AppendFormat("\t{0} = xxxxxxx{1}{2}\r\n", parameter.ParameterName.Substring(prefiexIndex), (num2++ < dbParameter.Length) ? "," : "", ((parameter.Direction == ParameterDirection.Output) || (parameter.Direction == ParameterDirection.InputOutput)) ? "\t\t// output" : "");
     }
     builder.AppendLine("};");
     if ((flag && flag2) && flag3)
     {
         builder.AppendFormat("List<TModel> list = DbHelper.FillListPaged<TModel>(\"{0}\", parameters);\r\n", spname);
         builder.AppendFormat("//List<TModel> list = DbHelper.FillList<TModel>(\"{0}\", parameters);\r\n", spname);
     }
     else if (((spname.IndexOf("get", StringComparison.OrdinalIgnoreCase) >= 0) || (spname.IndexOf("query", StringComparison.OrdinalIgnoreCase) >= 0)) || (spname.IndexOf("search", StringComparison.OrdinalIgnoreCase) >= 0))
     {
         if (dbParameter.Count(t => t.DbType == DbType.Object) > 0)
         {
             builder.AppendFormat("List<TModel> list = DbHelper.FillList<TModel>(\"{0}\", parameters);\r\n", spname);
         }
         else
         {
             builder.AppendFormat("TModel item = DbHelper.GetDataItem<TModel>(\"{0}\", parameters);\r\n", spname);
             builder.AppendFormat("//List<TModel> list = DbHelper.FillList<TModel>(\"{0}\", parameters);\r\n", spname);
         }
     }
//.........这里部分代码省略.........
开发者ID:nakijun,项目名称:FastDBEngine,代码行数:101,代码来源:GeneratorClassHelper.cs


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