本文整理汇总了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);
}
}
//.........这里部分代码省略.........