private int GetMaxRowIndex(Type objType) { object tempObj = objSpace.Evaluate(objType, CriteriaOperator.Parse("Max(RowIndex)"), null); if (tempObj != null & tempObj.GetType() == typeof(int)) { return((int)tempObj); } else { return(0); } }
private int GetAvailableSnatchLimit(string aSalesRepName) { // a sales rep can only grab X customer in a rolling 30 day period using (IObjectSpace os = Application.CreateObjectSpace()) { int apid = 1; ApplicationOptions ao = os.FindObject <ApplicationOptions>(new BinaryOperator("Ref", apid, BinaryOperatorType.Equal)); DateTime startdate = DateTime.Today.AddDays(-30); Object count = os.Evaluate(typeof(CustomerRelease), CriteriaOperator.Parse("Count()"), CriteriaOperator.Parse("[AquiredBy]=? and [AquiredDate] >= ?", aSalesRepName, startdate)); if (count != null) { return(ao.ThrityDayCustomerSnatchLimit - Convert.ToInt32(count)); } } return(0); }
public static object Evaluate(this IObjectSpace objectSpace, Type objectType, string field, Aggregate aggregate, CriteriaOperator filter = null) => objectSpace.Evaluate(objectType, CriteriaOperator.Parse($"{aggregate}({field})"), filter);
public static object Evaluate <T>(this IObjectSpace objectSpace, Expression <Func <T, object> > field, Aggregate aggregate, Func <Expression <Func <T, bool> > > filter = null) { filter ??= () => arg => true; return(objectSpace.Evaluate(typeof(T), CriteriaOperator.Parse($"{aggregate}({field.MemberExpressionName()})"), CriteriaOperator.FromLambda(filter()))); }