本文整理汇总了C#中Criteria.Find方法的典型用法代码示例。如果您正苦于以下问题:C# Criteria.Find方法的具体用法?C# Criteria.Find怎么用?C# Criteria.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria.Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllOrganizationList
public static SelectList AllOrganizationList()
{
var q = new Criteria<Organization>();
var d = q.Find();
d.Insert(0, new Organization { Id = 0, Name = "全部" });
return new SelectList(d, "Id", "Name");
}
示例2: AllSchoolSectionList
public static SelectList AllSchoolSectionList()
{
var q = new Criteria<Department>();
q.And(m => m.Type.Equals(DeparmentTypeList.Section));
var d = q.Find();
d.Insert(0, new Department { Id = 0, Name = "全部" });
return new SelectList(d, "Id", "Name");
}
示例3: GetScrollNotices
/// <summary>
/// 读取滚动公告
/// </summary>
/// <returns></returns>
public static IList<Notice> GetScrollNotices()
{
using (var session = new SessionFactory().OpenSession())
{
var today = DateTime.Today;
var q = new Criteria<Notice>(session).Where(m => m.StopAt >= today);
return q.Find();
}
}
示例4: ClassStudentList
public static SelectList ClassStudentList(long id)
{
var q = new Criteria<SchoolStudent>().Where(m => m.ClassId.Equals(id)).Asc(m => m.StudentNo);
var d = q.Find();
foreach (var x in d)
{
x.StudentName = "[" + x.StudentNo + "]" + x.StudentName;
}
return new SelectList(d, "StudentNo", "StudentName");
}
示例5: DepartmentList
public static SelectList DepartmentList()
{
var q = new Criteria<SchoolDepartment>();
var d = q.Find();
foreach (var item in d)
{
item.Name = string.Format("{0} [{1}]", item.Name, item.ShortName);
}
d.Insert(0, new SchoolDepartment { Id = 0, Name = "无" });
return new SelectList(d, "Id", "Name");
}
示例6: QuickSearch
public ActionResult QuickSearch(FormCollection collection, uint pagesize = DefaultPageSize, uint pageno = 1)
{
var keyword = GetDbQueryPara();
using (var session = new SessionFactory().OpenSession())
{
var q = new Criteria<TrainManagement>(session)
.Page(pagesize, pageno)
.Asc(m => m.Id)
.AddOrder(collection, ViewData)
//.AndUnless(string.IsNullOrEmpty(keyword), m => m.Name.Include(keyword))
;
var models = q.Find().PartPage(pageno, pagesize, q.Count());
return View(models);
}
}
示例7: QuickSearch
public ActionResult QuickSearch(FormCollection collection, uint pagesize = DefaultPageSize, uint pageno = 1)
{
using (var session = new SessionFactory().OpenSession())
{
var q = new Criteria<ActionLog>(session).Page(pagesize, pageno)
.Asc(m => m.CreatedAt).AddOrder(collection, ViewData);
if (collection != null)
{
if (collection.AllKeys.Contains("starttime"))
{
var dtStr = (collection["starttime"] + string.Empty).Trim();
if (!string.IsNullOrEmpty(dtStr))
{
DateTime startAt;
if (DateTime.TryParse(dtStr, out startAt))
{
q.And(m => m.CreatedAt >= startAt);
}
}
}
if (collection.AllKeys.Contains("endtime"))
{
var dtStr = (collection["endtime"] + string.Empty).Trim();
if (!string.IsNullOrEmpty(dtStr))
{
DateTime endAt;
if (DateTime.TryParse(dtStr, out endAt))
{
q.And(m => m.CreatedAt <= endAt);
}
}
}
if (collection.AllKeys.Contains("keywords"))
{
var keywords = (collection["keywords"] + string.Empty).Trim();
if (!string.IsNullOrEmpty(keywords))
{
q.And(m => m.Actor.Include(keywords), m => m.Category.Include(keywords),
m => m.Title.Include(keywords), m => m.Description.Include(keywords),
m => m.Result.Include(keywords));
}
}
}
var models = q.Find().PartPage(pageno, pagesize, q.Count());
return View(models);
}
}
示例8: QuickSearch
public ActionResult QuickSearch(FormCollection collection, long id = 0, uint pagesize = DefaultPageSize, uint pageno = 1)
{
var keyword = GetDbQueryPara();
using (var session = new SessionFactory().OpenSession())
{
var q = new Criteria<TrainExperienceView>(session)
.Page(pagesize, pageno)
.Asc(m => m.Id)
.AddOrder(collection, ViewData)
.And(m => m.Status.Equals(TrainExperienceConst.已提交培训管理部门), m => m.Status.Equals(TrainExperienceConst.已提交领导))
.And(m => m.TrainManId.Equals(id))
.AndUnless(string.IsNullOrEmpty(keyword), m => m.Year.Equals(keyword), m => m.Dept.Include(keyword), m => m.StaffName.Include(keyword))
;
var models = q.Find().PartPage(pageno, pagesize, q.Count());
return View(models);
}
}
示例9: QuickSearch
public ActionResult QuickSearch(FormCollection collection, uint pagesize = DefaultPageSize, uint pageno = 1)
{
var keywords = GetDbQueryPara();
using (var session = new SessionFactory().OpenSession())
{
var q = new Criteria<StandardFile>(session).Page(pagesize, pageno).Asc(m => m.Id).AddOrder(collection, ViewData)
.And(m => m.State.Equals(StandardFileStateConst.已发布))
.AndUnless(string.IsNullOrEmpty(keywords),
m => m.OriginName.Include(keywords),
m => m.FileType.Include(keywords),
m => m.Creator.Include(keywords),
m => m.Description.Include(keywords),
m => m.Memo.Include(keywords),
m => m.State.Include(keywords),
m => m.ApproveState.Include(keywords));
var models = q.Find().PartPage(pageno, pagesize, q.Count());
return View(models);
}
}
示例10: GetManItem
public ActionResult GetManItem(FormCollection collection)
{
var q = new Criteria<TrainManagementItem>()
.And(m => m.StaffCode.Equals(CurrentAccountNo))
.Desc(m => m.Year);
var model = q.Find();
return JsonData(new SelectList(model, "TrainManName", "Id"));
}
示例11: UserList
public static SelectList UserList()
{
var q = new Criteria<User>();
var d = q.Find();
return new SelectList(d, "Name", "Realname");
}
示例12: TeacherList
public static SelectList TeacherList()
{
var q = new Criteria<User>();
var d = q.Find();
foreach (User x in d)
{
x.Name = x.Code + "|" + x.Realname;
}
d.Insert(0, new User { Id = 0, Name = "无" });
return new SelectList(d, "Name", "Name");
}
示例13: Pintask
public ActionResult Pintask(long[] ids)
{
if (ids.Length == 0)
{
FlashInfo("请选择要查看用户的角色。");
return Close();
}
using (var session = new SessionFactory().OpenSession())
{
var roles = session.Find<Role>(m => m.Id.In(ids));
if (roles == null || roles.Count == 0)
{
FlashInfo("请选择要查看用户的角色。");
return Close();
}
ViewData["roleName"] = string.Join(",", roles.Select(m => m.Name));
var q = new Criteria<Navigation>().Select(m => m.Id).AndIn<AccountNavigationRef>(x => x.Id, y => y.NavigationId,
p => p.Type.Equals(AccountNavigationRef.RoleType) && p.OwnerId.In(ids));
ViewData["selectedIds"] = q.PropertieValues<long>();
var q2 = new Criteria<Navigation>().AndIn<NavigationPriviledge>(m => m.Id, n => n.NavigationId,
n => n.Flag.Equals(NavigationPriviledge.RoleType) && n.OwnerId.In(ids))
.And(p => p.Type.Equals(NavigationType.Module));
var model = q2.Find().ToOrderList();
return View(model);
}
}
示例14: RoleName
public String RoleName()
{
if (IsSystem) return "系统管理员";
var q = new Criteria<AccountRoleRef>().Where(m => m.AccountId.Equals(Id));
var refs = q.Find();
if (refs.Count == 0) return "无角色";
var db = new SessionFactory().OpenSession();
var ids = refs.Select(m => m.RoleId).ToArray();
var roles = db.Find<Role>(m => m.Id.In(ids));
return roles.Count == 0 ? "无角色" : string.Join(", ", roles.Select(m => m.Name));
}
示例15: QuickSearch
public ActionResult QuickSearch(FormCollection collection, uint pagesize = DefaultPageSize, uint pageno = 1)
{
var keywords = GetDbQueryPara();
using (var session = new SessionFactory().OpenSession())
{
var q = new Criteria<Dossier>(session)
.Page(pagesize, pageno)
.Asc(m => m.Id)
.AddOrder(collection, ViewData)
.AndUnless(string.IsNullOrEmpty(keywords), m => m.Name.Include(keywords),
m => m.ContractNo.Include(keywords),
m => m.Undertaker.Include(keywords),
m => m.Type.Include(keywords),
m => m.State.Include(keywords),
m => m.ApproveState.Include(keywords))
;
var models = q.Find().PartPage(pageno, pagesize, q.Count());
return View(models);
}
}