本文整理汇总了C#中DetachedCriteria类的典型用法代码示例。如果您正苦于以下问题:C# DetachedCriteria类的具体用法?C# DetachedCriteria怎么用?C# DetachedCriteria使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DetachedCriteria类属于命名空间,在下文中一共展示了DetachedCriteria类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitPageParameter
public void InitPageParameter(DetachedCriteria criteria)
{
IList<PlannedBill> plannedBillList = TheCriteriaMgr.FindAll<PlannedBill>(criteria);
this.MatchList = this.ConvertPlannedBillToTransformer(plannedBillList);
this.BindList();
this.tbItemCode.Focus();
}
示例2: CriteriaCompiled
/// <summary>
///
/// </summary>
/// <param name="rootAlias"></param>
/// <param name="rootType"></param>
/// <param name="matchMode"></param>
/// <param name="entityMode"></param>
/// <param name="instance"></param>
/// <param name="classInfoProvider"></param>
public CriteriaCompiled(string rootAlias, System.Type rootType, MatchMode matchMode, EntityMode entityMode,
object instance, Func<System.Type, IPersistentClassInfo> classInfoProvider)
{
if (rootAlias == null || rootAlias.Trim().Equals(string.Empty))
throw new ArgumentException("The alias for making detached criteria cannot be empty or null", "rootAlias");
if (rootType == null)
throw new ArgumentNullException("rootType", "The type which can be used for maikng detached criteria cannot be null.");
if (instance == null)
throw new ArgumentNullException("instance", "The instance for building detached criteria cannot be null.");
if (!rootType.IsInstanceOfType(instance))
throw new ArgumentTypeException("The given instance for building detached criteria is not suitable for the given criteria type.", "instance", rootType, instance.GetType());
this.matchMode = matchMode ?? MatchMode.Exact;
this.entityMode = entityMode;
this.instance = instance;
this.classInfoProvider = classInfoProvider;
this.relationshipTree = new RelationshipTree(rootAlias, rootType);
this.criteria = DetachedCriteria.For(rootType, rootAlias);
this.restrictions = new List<ICriterion>();
this.Init();
}
示例3: SubqueryExpression
protected SubqueryExpression(String op, String quantifier, DetachedCriteria dc, bool prefixOp)
{
criteriaImpl = dc.GetCriteriaImpl();
this.quantifier = quantifier;
this.prefixOp = prefixOp;
this.op = op;
}
示例4: TransformToRowCount
///<summary>
/// Returns a clone of the original criteria, which will return the count
/// of rows that are returned by the original criteria query.
///</summary>
public static DetachedCriteria TransformToRowCount(DetachedCriteria criteria)
{
ICriteria clonedCriteria = TransformToRowCount(criteria.GetCriteriaImpl());
DetachedCriteria detachedCriteria = DetachedCriteria.For(clonedCriteria.CriteriaClass, clonedCriteria.Alias);
detachedCriteria.SetCriteriaImpl((CriteriaImpl) clonedCriteria);
return detachedCriteria;
}
示例5: AddUserSelectCriteria
public void AddUserSelectCriteria(string cacheKey, DetachedCriteria selectCriteria, DetachedCriteria selectCountCriteria, IDictionary<string, string> alias)
{
if (_page.Session["SelectCriteriaCache"] == null)
{
_page.Session["SelectCriteriaCache"] = new Dictionary<string, CachedSelectCriteria>();
}
IDictionary<string, CachedSelectCriteria> selectCriteriaCache = (IDictionary<string, CachedSelectCriteria>)_page.Session["SelectCriteriaCache"];
if (!selectCriteriaCache.ContainsKey(cacheKey) && selectCriteriaCache.Count > UserSelectCriteriaCacheSize)
{
//Cache��������UserSelectCriteria
DateTime lastestTime = DateTime.Now;
string lastestkey = string.Empty;
foreach (string key in selectCriteriaCache.Keys)
{
CachedSelectCriteria cache = selectCriteriaCache[key];
if (lastestTime > cache.LastAccessTime)
{
lastestkey = key;
}
}
selectCriteriaCache.Remove(lastestkey);
}
if (selectCriteriaCache.ContainsKey(cacheKey))
{
selectCriteriaCache[cacheKey] = new CachedSelectCriteria(DateTime.Now, selectCriteria, selectCountCriteria, alias);
}
else
{
selectCriteriaCache.Add(cacheKey, new CachedSelectCriteria(DateTime.Now, selectCriteria, selectCountCriteria, alias));
}
}
示例6: Add
public IMultiCriteria Add(DetachedCriteria detachedCriteria)
{
criteriaQueries.Add(
detachedCriteria.GetExecutableCriteria(session)
);
return this;
}
示例7: FindCount
public int FindCount(DetachedCriteria selectCriteria)
{
IList list = CriteriaMgr.FindAll(selectCriteria);
if (list != null && list.Count > 0)
{
if (list[0] is int)
{
return int.Parse(list[0].ToString());
}
else if (list[0] is object[])
{
return int.Parse(((object[])list[0])[0].ToString());
}
//由于性能问题,此后禁用该方法。
//else if (list[0] is object)
//{
// return list.Count;
//}
else
{
throw new Exception("unknow result type");
}
}
else
{
return 0;
}
}
示例8: GetPermissionCriteriaByCategory
public static DetachedCriteria[] GetPermissionCriteriaByCategory(User user, string category)
{
DetachedCriteria[] criteria = new DetachedCriteria[2];
DetachedCriteria upSubCriteria = DetachedCriteria.For<UserPermission>();
upSubCriteria.CreateAlias("User", "u");
upSubCriteria.CreateAlias("Permission", "pm");
upSubCriteria.CreateAlias("pm.Category", "pmc");
upSubCriteria.Add(Expression.Eq("pmc.Type", category));
upSubCriteria.Add(Expression.Eq("u.Code", user.Code));
upSubCriteria.SetProjection(Projections.ProjectionList().Add(Projections.GroupProperty("pm.Code")));
DetachedCriteria rpSubCriteria = DetachedCriteria.For<RolePermission>();
rpSubCriteria.CreateAlias("Role", "r");
rpSubCriteria.CreateAlias("Permission", "pm");
rpSubCriteria.CreateAlias("pm.Category", "pmc");
rpSubCriteria.Add(Expression.Eq("pmc.Type", category));
rpSubCriteria.SetProjection(Projections.ProjectionList().Add(Projections.GroupProperty("pm.Code")));
DetachedCriteria urSubCriteria = DetachedCriteria.For<UserRole>();
urSubCriteria.CreateAlias("User", "u");
urSubCriteria.CreateAlias("Role", "r");
urSubCriteria.Add(Expression.Eq("u.Code", user.Code));
urSubCriteria.SetProjection(Projections.ProjectionList().Add(Projections.GroupProperty("r.Code")));
rpSubCriteria.Add(Subqueries.PropertyIn("r.Code", urSubCriteria));
criteria[0] = upSubCriteria;
criteria[1] = rpSubCriteria;
return criteria;
}
示例9: BindDataSource
public void BindDataSource(DetachedCriteria selectCriteria)
{
IList<PlannedBill> plannedBillList = TheCriteriaMgr.FindAll<PlannedBill>(selectCriteria);
this.AutoCalculate(plannedBillList);
this.GV_List.DataSource = plannedBillList;
this.GV_List.DataBind();
UpdateView();
}
示例10: BindDataSource
public void BindDataSource(DetachedCriteria selectCriteria, bool isExport)
{
IList<PlannedBill> plannedBills = TheCriteriaMgr.FindAll<PlannedBill>(selectCriteria);
if (IsSupplier)
{
plannedBills = (from p in plannedBills
group p by new { p.Item, p.OrderNo, p.ReceiptNo, p.BillAddress, p.Uom, p.CreateDate, p.UnitPrice, p.Currency } into g
select new PlannedBill
{
Item = g.Key.Item,
OrderNo = g.Key.OrderNo,
ReceiptNo = g.Key.ReceiptNo,
BillAddress = g.Key.BillAddress,
Uom = g.Key.Uom,
CreateDate = g.Key.CreateDate,
UnitPrice = g.Key.UnitPrice,
Currency = g.Key.Currency,
PlannedQty = g.Sum(p => p.PlannedQty),
PlannedAmount = g.Sum(p => p.PlannedAmount),
ActingQty = g.Sum(p => p.ActingQty),
ActingAmount = g.Sum(p => p.ActingAmount)
})
//.Where(p => this.CurrentUser.HasPermission(p.BillAddress.Party.Code))
.ToList();
}
plannedBills = plannedBills.OrderBy(p => p.CreateDate).OrderBy(p => p.Item.Code).ToList();
this.GV_List.DataSource = plannedBills;
this.GV_List.DataBind();
UpdateView();
if (isExport && GV_List.Rows.Count > 0)
{
string dateTime = DateTime.Now.ToString("MMddhhmmss");
int lastColumnIndex = GV_List.Columns.Count - 1;
DataControlField dataControlField0 = null;
//DataControlField dataControlFieldLast = null;
if (!IsSupplier)
{
dataControlField0 = GV_List.Columns[0];
//dataControlFieldLast = GV_List.Columns[lastColumnIndex];
//GV_List.Columns.RemoveAt(lastColumnIndex);
GV_List.Columns.RemoveAt(0);
}
this.ExportXLS(GV_List, "PlanBill" + dateTime + ".xls");
if (!IsSupplier)
{
GV_List.Columns.Insert(0, dataControlField0);
//GV_List.Columns.Insert(lastColumnIndex-1, dataControlFieldLast);
}
}
}
示例11: SerializeAndList
private void SerializeAndList(DetachedCriteria dc)
{
byte[] bytes = SerializationHelper.Serialize(dc);
DetachedCriteria dcs = (DetachedCriteria)SerializationHelper.Deserialize(bytes);
using (ISession s = OpenSession())
{
dcs.GetExecutableCriteria(s).List();
}
}
示例12: AssertCriteriaAreNotEqual
private void AssertCriteriaAreNotEqual(DetachedCriteria expected, DetachedCriteria actual)
{
try
{
AssertCriteriaAreEqual(expected, actual);
}
catch
{
return;
}
Assert.Fail("No exception thrown");
}
示例13: GetRootType
public static Type GetRootType(DetachedCriteria criteria, ISession session)
{
Type rootType = criteria.GetRootEntityTypeIfAvailable();
if (rootType != null)
{
return rootType;
}
ISessionFactoryImplementor factory = (ISessionFactoryImplementor)session.SessionFactory;
IEntityPersister persister = factory.GetEntityPersister(criteria.EntityOrClassName);
if (persister == null)
throw new InvalidOperationException("Could not find entity named: " + criteria.EntityOrClassName);
return persister.GetMappedClass(EntityMode.Poco);
}
示例14: InitPageParameter
public void InitPageParameter(DetachedCriteria selectCriteria)
{
this.InspectCriteria = selectCriteria;
IList<InspectOrderDetail> pendingInspectOrderDetailList = TheCriteriaMgr.FindAll<InspectOrderDetail>(selectCriteria);
this.GV_List.DataSource = pendingInspectOrderDetailList;
this.GV_List.DataBind();
if (pendingInspectOrderDetailList.Count == 0)
{
this.lblMessage.Visible = true;
this.lblMessage.Text = "${Common.GridView.NoRecordFound}";
}
else
{
this.lblMessage.Visible = false;
}
}
示例15: InitPageParameter
public void InitPageParameter(DetachedCriteria selectCriteria)
{
IList<OrderHead> orderHeadList = TheCriteriaMgr.FindAll<OrderHead>(selectCriteria);
this.GV_List.DataSource = orderHeadList;
this.GV_List.DataBind();
if (orderHeadList.Count == 0)
{
this.lblMessage.Visible = true;
this.lblMessage.Text = "${Common.GridView.NoRecordFound}";
this.btnPrint.Visible = false;
}
else
{
this.lblMessage.Visible = false;
this.btnPrint.Visible = true;
}
}