本文整理汇总了C#中SqlQuery.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SqlQuery.Clear方法的具体用法?C# SqlQuery.Clear怎么用?C# SqlQuery.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlQuery
的用法示例。
在下文中一共展示了SqlQuery.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSequenceName
private static string GetSequenceName(IDbAccess dataAccess, string tableName, string pkColumnName, bool checkSequence)
{
if (dataAccess == null)
throw new ArgumentNullException(nameof(dataAccess));
if (String.IsNullOrEmpty(tableName))
throw new ArgumentNullException(nameof(tableName));
if (String.IsNullOrEmpty(pkColumnName))
throw new ArgumentNullException(nameof(pkColumnName));
string[] arr = tableName.Split('.');
bool withUser = arr.Length > 1;
string sequenceName = null;
if (withUser)
sequenceName = arr[0] + ".SQE_" + arr[1];
else
sequenceName = "SQE_" + tableName;
if (checkSequence)
{
object temp = null;
decimal ret = 0M, minVal = 1M, curVal = 0M;
SqlQuery query = new SqlQuery();
StringBuilder text = query.Text;
try
{
text.Append("SELECT MAX(");
text.Append(tableName);
text.Append('.');
text.Append(pkColumnName);
text.Append(") FROM ");
text.Append(tableName);
temp = dataAccess.ExecuteScalar(query);
if (temp != null && temp.GetType() != CachedTypes.DBNull)
{
minVal = ((Decimal)temp) + 1M;
}
query.Clear();
text = query.Text;
text.Append(" SELECT COUNT(*) FROM");
if (withUser)
{
text.Append(" ALL_SEQUENCES T WHERE T.SEQUENCE_OWNER = :SEQUENCE_OWNER AND");
query.Parameters.Add("SEQUENCE_OWNER", arr[0]);
query.Parameters.Add("SEQUENCE_NAME", "SQE_" + arr[1]);
}
else
{
text.Append(" USER_SEQUENCES T WHERE");
query.Parameters.Add("SEQUENCE_NAME", sequenceName);
}
text.Append(" T.SEQUENCE_NAME = :SEQUENCE_NAME");
ret = (Decimal)dataAccess.ExecuteScalar(query);
if (ret == 0M)
{
query.Clear();
text = query.Text;
text.Append("CREATE SEQUENCE ");
text.Append(sequenceName);
text.AppendLine();
text.Append("MINVALUE 0");
text.AppendLine();
text.Append("MAXVALUE 9999999999999999999999999");
text.AppendLine();
text.Append("START WITH ");
text.Append(minVal);
text.AppendLine();
text.Append("INCREMENT BY 1");
text.AppendLine();
text.Append("CACHE 20");
text.AppendLine();
dataAccess.ExecuteNonQuery(query);
}
else
{
query.Clear();
text = query.Text;
text.Append("SELECT T.LAST_NUMBER FROM");
if (withUser)
{
text.Append(" ALL_SEQUENCES T WHERE T.SEQUENCE_OWNER = :SEQUENCE_OWNER AND T.SEQUENCE_NAME = :SEQUENCE_NAME");
query.Parameters.Add("SEQUENCE_OWNER", arr[0]);
query.Parameters.Add("SEQUENCE_NAME", "SQE_" + arr[1]);
}
else
{
text.Append(" USER_SEQUENCES T WHERE T.SEQUENCE_NAME = :SEQUENCE_NAME");
query.Parameters.Add("SEQUENCE_NAME", sequenceName);
}
curVal = (Decimal)dataAccess.ExecuteScalar(query);
if (minVal > curVal)
{
query.Clear();
text = query.Text;
//.........这里部分代码省略.........