本文整理汇总了C#中Utilities.SQL.SQLHelper.Any方法的典型用法代码示例。如果您正苦于以下问题:C# SQLHelper.Any方法的具体用法?C# SQLHelper.Any怎么用?C# SQLHelper.Any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities.SQL.SQLHelper
的用法示例。
在下文中一共展示了SQLHelper.Any方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Any
public void Any()
{
Utilities.SQL.SQLHelper.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_")
.Map(x => x.ID, "ID_")
.Map(x => x.StringValue, "StringValue_")
.Map(x => x.FloatValue, "FloatValue_")
.Map(x => x.BoolValue, "BoolValue_")
.Map(x => x.LongValue, "LongValue_");
ObjectClass1 TempObject = new ObjectClass1();
using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper())
{
TempObject.StringValue = "Test String";
TempObject.BoolValue = true;
TempObject.FloatValue = 1234.5f;
TempObject.LongValue = 12345;
ORM.Save<ObjectClass1,int>(TempObject);
TempObject = null;
TempObject = ORM.Any<ObjectClass1>();
Assert.Equal("Test String", TempObject.StringValue);
Assert.Equal(1234.5f, TempObject.FloatValue);
Assert.Equal(true, TempObject.BoolValue);
Assert.Equal(12345, TempObject.LongValue);
Assert.Equal(1, TempObject.ID);
}
}
示例2: Any
public void Any()
{
using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
{
Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_");
TestObject.Map(x => x.ID, "ID_")
.Map(x => x.StringValue, "StringValue_")
.Map(x => x.FloatValue, "FloatValue_")
.Map(x => x.BoolValue, "BoolValue_")
.Map(x => x.LongValue, "LongValue_")
.Map(x => x.StringMaxValue, "StringMaxValue_");
Utilities.Random.Random Rand = new Utilities.Random.Random(12345);
ObjectClass1 TempObject = new ObjectClass1();
TempObject.StringValue = "Test String";
TempObject.BoolValue = true;
TempObject.FloatValue = 1234.5f;
TempObject.LongValue = 12345;
TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
string StringMaxValue = TempObject.StringMaxValue;
Helper2.Save<ObjectClass1, int>(TempObject);
TempObject = Helper2.Any<ObjectClass1>();
Assert.Equal("Test String", TempObject.StringValue);
Assert.Equal(1234.5f, TempObject.FloatValue);
Assert.Equal(true, TempObject.BoolValue);
Assert.Equal(12345, TempObject.LongValue);
Assert.Equal(1, TempObject.ID);
Assert.Equal(StringMaxValue, TempObject.StringMaxValue);
}
}
示例3: AnyDifferentParameterTypes
public void AnyDifferentParameterTypes()
{
Utilities.SQL.SQLHelper.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_")
.Map(x => x.ID, "ID_")
.Map(x => x.StringValue, "StringValue_")
.Map(x => x.FloatValue, "FloatValue_")
.Map(x => x.BoolValue, "BoolValue_")
.Map(x => x.LongValue, "LongValue_");
for (int x = 0; x < 30; ++x)
{
using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper())
{
ObjectClass1 TempObject = new ObjectClass1();
TempObject.StringValue = "Test String";
TempObject.BoolValue = true;
TempObject.FloatValue = 1234.5f;
TempObject.LongValue = x;
TempObject.ID = ORM.Insert<ObjectClass1, int>(TempObject);
}
}
using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper())
{
ObjectClass1 TempObject = ORM.Any<ObjectClass1>("*", null, null, false, new EqualParameter<long>(20, "LongValue_"));
Assert.Equal(21, TempObject.ID);
Assert.Equal(20, TempObject.LongValue);
IEnumerable<ObjectClass1> TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new NotEqualParameter<long>(20, "LongValue_"));
Assert.Equal(29, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new BetweenParameter<long>(20, 25, "LongValue_"));
Assert.Equal(6, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new AndParameter(new BetweenParameter<long>(20, 25, "LongValue_"), new NotEqualParameter<long>(20, "LongValue_")));
Assert.Equal(5, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new OrParameter(new BetweenParameter<long>(20, 25, "LongValue_"), new EqualParameter<long>(29, "LongValue_")));
Assert.Equal(7, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new LikeParameter("Test%", "StringValue_", 100));
Assert.Equal(30, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new LikeParameter("Test2%", "StringValue_", 100));
Assert.Equal(0, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null, false, new StringEqualParameter("Test String", "StringValue_", 100));
Assert.Equal(30, TempObjects.Count());
TempObjects = ORM.All<ObjectClass1>("*", 0, "", null, null,false, new StringNotEqualParameter("Test String", "StringValue_", 100));
Assert.Equal(0, TempObjects.Count());
}
}