本文整理汇总了C#中Session.ExecuteQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Session.ExecuteQuery方法的具体用法?C# Session.ExecuteQuery怎么用?C# Session.ExecuteQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.ExecuteQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryCompiler_Assert_PreCompiledQuery_Parameter_Value_Changes
public void QueryCompiler_Assert_PreCompiledQuery_Parameter_Value_Changes()
{
// basic precompiled query.
IQueryCompilerLevel2<Employee> query = Select.All.From<Employee>()
.Where(e => e.EmployeeId > Param.Get<int>());
using (var session = new Session())
{
Assert.That(session.ExecuteQuery(query, 1).Count(), Is.EqualTo(8));
Assert.That(session.ExecuteQuery(query, 2).Count(), Is.EqualTo(7));
}
}
示例2: QueryCompiler_Assert_PreCompiledQuery_Parameters_SetBy_IEnumerable
public void QueryCompiler_Assert_PreCompiledQuery_Parameters_SetBy_IEnumerable()
{
// basic precompiled query.
IQueryCompilerLevel2<Employee> query = Select.All.From<Employee>()
.Where(e => e.EmployeeId > Param.Get<int>())
.And(e => e.EmployeeId < Param.Get<int>());
using (var session = new Session())
{
Assert.That(session.ExecuteQuery(query, new[] { 1, 8 }).Count(), Is.EqualTo(6));
Assert.That(session.ExecuteQuery(query, 1, 8).Count(), Is.EqualTo(6));
}
}
示例3: GetNavIdByName
/// <summary>
/// 根据导航名称获取导航序号
/// </summary>
/// <param name="session"></param>
/// <param name="name"></param>
/// <returns></returns>
private long GetNavIdByName(Session session, string name)
{
var assignmentSql = string.Format(@"INSERT IGNORE INTO `nav_name_dicts`(`name`) VALUES('{0}'); SELECT `id` FROM `nav_name_dicts` WHERE `name` = '{0}';", name);
var ids = session.ExecuteQuery<long>(assignmentSql);
if (ids.Count == 0)
{
throw new Exception(string.Format("注册导航名称{0}失败", name));
}
if (ids.Count != 1)
{
throw new Exception(string.Format("导航名称 {0} 重复", name));
}
return ids[0];
}
示例4: CreateNewRowTimekeeping
private void CreateNewRowTimekeeping(Session session, string value,
Guid loaiDuLieuChamCongOid, Guid tenBangChamCongOid, Guid nhanVienOid, Guid PhongBanOid, int index, ref List<string> strArr)
{
string s = string.Format("SELECT * FROM \"TimekeepingMonth\" WHERE" +
"\"TimekeepingName\" = '{0}' AND \"Employee\" = '{1}' AND \"DataTypeTimekeeping\" = '{2}'",
tenBangChamCongOid, nhanVienOid, loaiDuLieuChamCongOid);
SelectedData data = session.ExecuteQuery(s);
//if(session.FindObject<TimekeepingMonth>(CriteriaOperator.And(new BinaryOperator("TimekeepingName.Oid", tenBangChamCongOid),
// new BinaryOperator("Employee.Oid",nhanVienOid), new BinaryOperator("DataTypeTimekeeping.Oid",loaiDuLieuChamCongOid))) == null)
if(data.ResultSet[0].Rows.Length == 0)
{
session.BeginTransaction();
Guid id = Guid.NewGuid();
while (true)
{
try
{
s = string.Format("INSERT INTO \"TimekeepingMonth\" (\"Oid\",\"TimekeepingName\", \"Employee\", \"Department\", \"DataTypeTimekeeping\", \"Ngay" + index.ToString() + "\")" +
"VALUES ('{4}','{0}','{1}','{2}','{3}')", tenBangChamCongOid, nhanVienOid, PhongBanOid, loaiDuLieuChamCongOid, value, id);
session.ExecuteNonQuery(s);
break;
}
catch
{
id = Guid.NewGuid();
}
}
session.CommitTransaction();
}
else
{
strArr.Add(string.Format("UPDATE \"TimekeepingMonth\" SET \"Ngay" + index.ToString() + "\" = '{3}', \"Department\" = '{4}', \"OptimisticLockField\" = null, \"GCRecord\" = null WHERE " +
"\"TimekeepingName\" = '{0}' AND \"Employee\" = '{1}' AND \"DataTypeTimekeeping\" = '{2}'",
tenBangChamCongOid, nhanVienOid, loaiDuLieuChamCongOid, value,PhongBanOid));
}
}