本文整理汇总了C#中SQL.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SQL.ToString方法的具体用法?C# SQL.ToString怎么用?C# SQL.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Return_Simple_Delete_From_Table
public void Should_Return_Simple_Delete_From_Table()
{
var expected = "DELETE FROM table";
var sql = new SQL();
sql.Delete().From("table");
Assert.AreEqual(expected, sql.ToString());
}
示例2: Should_Return_Update_On_One_Field_From_One_Table_With_Where
public void Should_Return_Update_On_One_Field_From_One_Table_With_Where()
{
var expected = "UPDATE table SET f = ? WHERE (FieldOne = ValueOne)";
var sql = new SQL();
sql.Update().Table("table").Set("f", "?").Where("FieldOne = ValueOne");
Assert.AreEqual(expected, sql.ToString());
}
示例3: Should_Return_Update_On_One_Field_From_One_Table
public void Should_Return_Update_On_One_Field_From_One_Table()
{
var expected = "UPDATE table SET f = ?";
var sql = new SQL();
sql.Update().Table("table").Set("f","?");
Assert.AreEqual(expected, sql.ToString());
}
示例4: Should_Return_Simple_Delete_From_Table_With_Some_Where
public void Should_Return_Simple_Delete_From_Table_With_Some_Where()
{
var expected = "DELETE FROM students WHERE (id > 5) AND (id < 102)";
var sql = new SQL();
sql.Delete()
.From("students")
.Where("id > 5")
.Where("id < 102");
Assert.AreEqual(expected, sql.ToString());
}
示例5: Should_Return_Insert_In_One_Table
public void Should_Return_Insert_In_One_Table()
{
var expected = "INSERT INTO students (name) VALUES (Thomas)";
var sql = new SQL();
sql.Insert()
.Into("students")
.Set("name", "Thomas");
Assert.AreEqual(expected, sql.ToString());
}
示例6: Should_Return_Update_With_Some_Set_From_One_Table_With_NULL
public void Should_Return_Update_With_Some_Set_From_One_Table_With_NULL()
{
var expected = "UPDATE students SET name = 'Fred', age = 29, score = 1.2, nichname = NULL";
var sql = new SQL();
sql.Update()
.Table("students")
.Set("name", "'Fred'")
.Set("age", 29)
.Set("score", 1.2)
.Set("nichname", null);
Assert.AreEqual(expected, sql.ToString());
}
示例7: Should_Return_Insert_With_Some_Sets_From_One_Table
public void Should_Return_Insert_With_Some_Sets_From_One_Table()
{
var expected = "INSERT INTO students (name, age, score, graduate, nickname) VALUES (Thomas, 29, 90.2, True, NULL)";
var sql = new SQL();
sql.Insert()
.Into("students")
.Set("name", "Thomas")
.Set("age", 29)
.Set("score", 90.2)
.Set("graduate", true)
.Set("nickname", null);
Assert.AreEqual(expected, sql.ToString());
}
示例8: Should_Return_Complex_Expression
public void Should_Return_Complex_Expression()
{
var expected = "id < 500 AND (id > 100 OR name <> 'Thomas') AND (age BETWEEN 20 AND 25 OR name <> 'Fred') OR nickname = 'Hardy'";
var sql = new SQL();
sql.Expr()
.And("id < 500")
.AndBegin()
.Or("id > 100")
.Or("name <> 'Thomas'")
.End()
.AndBegin()
.Or("age BETWEEN 20 AND 25")
.Or("name <> 'Fred'")
.End()
.Or("nickname = 'Hardy'");
Assert.AreEqual(expected, sql.ToString());
}
示例9: SerializeLogicalOperator
public virtual string SerializeLogicalOperator(SQL.LogicalOperator eLogicalOperator)
{
string strLogicalOperator;
if (eLogicalOperator == LogicalOperator.And)
strLogicalOperator = "AND";
else if (eLogicalOperator == LogicalOperator.Or)
strLogicalOperator = "OR";
else
throw new NotSupportedException(eLogicalOperator.ToString());
return strLogicalOperator;
}
示例10: SerializeAggregateFunction
public virtual string SerializeAggregateFunction(SQL.AggregateFunction aggregate)
{
switch (aggregate)
{
case AggregateFunction.Average:
return "AVG";
case AggregateFunction.Count:
return "COUNT";
case AggregateFunction.Sum:
return "SUM";
case AggregateFunction.Minimum:
return "MIN";
case AggregateFunction.Maximum:
return "MAX";
case AggregateFunction.StandardDeviation:
return "STDEV";
case AggregateFunction.Variance:
return "VAR";
default:
throw new NotSupportedException(aggregate.ToString());
}
}
示例11: SerializeDataType
public virtual string SerializeDataType(SQL.DataType dataType, int intSize, int intPrecision, int intScale)
{
throw new NotImplementedException("Data type " + dataType.ToString() + " is not implemented for " + this.GetType().Name);
}
示例12: SerializeComparisonOperator
public virtual string SerializeComparisonOperator(SQL.ComparisonOperator compare)
{
switch (compare)
{
case ComparisonOperator.EqualTo:
return "=";
case ComparisonOperator.NotEqualTo:
return "<>";
case ComparisonOperator.LessThan:
return "<";
case ComparisonOperator.LessThanOrEqualTo:
return "<=";
case ComparisonOperator.GreaterThan:
return ">";
case ComparisonOperator.GreaterThanOrEqualTo:
return ">=";
case ComparisonOperator.Like:
return "LIKE";
case ComparisonOperator.NotLike:
return "NOT LIKE";
default:
throw new NotSupportedException(compare.ToString());
}
}
示例13: SerializeBitwiseOperator
public virtual string SerializeBitwiseOperator(SQL.BitwiseOperator eOperator)
{
if (eOperator == BitwiseOperator.And)
return "&";
else if (eOperator == BitwiseOperator.Or)
return "|";
else
throw new NotSupportedException(eOperator.ToString());
}
示例14: SerializeArithmeticOperator
public string SerializeArithmeticOperator(SQL.ArithmeticOperator @operator)
{
switch (@operator)
{
case ArithmeticOperator.Add:
return "+";
case ArithmeticOperator.Subtract:
return "-";
case ArithmeticOperator.Multiply:
return "*";
case ArithmeticOperator.Divide:
return "/";
case ArithmeticOperator.Modulus:
return "%";
default:
throw new NotSupportedException(@operator.ToString());
}
}
示例15: Insert
/// <summary>
/// ��ȡIP������Ӽ�¼
/// </summary>
/// <param name="ipSetting">��ȡIP����ʵ����</param>
/// <param name="delCache">��ӳɹ��������CACHE key��֧������</param>
/// <param name="dbkey">�������ݿ����ӳ��е�����key��Ϊ��ʱʹ��ConnString����</param>
/// <returns>������ӳɹ����ID</returns>
public static Int64 Insert(IpSetting ipSetting, string dbkey = "", string[] delCache = null)
{
object obj = new SQL().Database(dbkey).Insert(IpSetting._)
.ValueP(IpSetting._IPCID, ipSetting.IPCID)
.ValueP(IpSetting._WebName, ipSetting.WebName)
.ValueP(IpSetting._IPUrl, ipSetting.IPUrl)
.ValueP(IpSetting._IPRegex, ipSetting.IPRegex)
.ValueP(IpSetting._DataEncode, ipSetting.DataEncode)
.ToExec();
if (obj.ToInt() != 1) return 0;
obj = new SQL().Database(dbkey).From(IpSetting._).Max("IPCID").ToScalar();
if (obj.IsAllNull()) return 0;
Int64 value = obj.ToString().ToBigInt();
if (delCache.IsNull()) return value;
Cache2.Remove("TH.Mailer.IpSettingCache_", delCache);
return value;
}