public IJoinSourceQueryBuilder <TRecord> On(string leftField, JoinOperand operand, string rightField) { var newClause = new JoinClause(leftField, operand, rightField); clauses.Add(newClause); return(this); }
protected override void OnActivated() { base.OnActivated(); Doctor curDoctor = (Doctor)SecuritySystem.CurrentUser; bool isAdmin = curDoctor.DoctorRoles.Any(t => t.IsAdministrative); if (!isAdmin) { CriteriaOperator criteria = new JoinOperand(typeof(CommonCase).FullName, CommonCase.Fields.DateIn >= DateTime.Today & CommonCase.Fields.Doctor.Oid == curDoctor.Oid & CommonCase.Fields.Pacient.Oid == new OperandProperty("^.Oid")) | new JoinOperand(typeof(DoctorEvent).FullName, DoctorEvent.Fields.Pacient.Oid == new OperandProperty("^.Oid") & DoctorEvent.Fields.AssignedTo.Oid == curDoctor.Oid & DoctorEvent.Fields.StartOn >= DateTime.Today & DoctorEvent.Fields.StartOn < DateTime.Today.AddDays(1)); ((ListView)View).CollectionSource.BeginUpdateCriteria(); ((ListView)View).CollectionSource.Criteria.Clear(); ((ListView)View).CollectionSource.Criteria[FILTERKEY] = criteria; ((ListView)View).CollectionSource.EndUpdateCriteria(); } }
public JoinClause(string leftTableAlias, string leftFieldName, JoinOperand operand, string rightTableAlias, string rightFieldName) { this.leftTableAlias = leftTableAlias; this.leftFieldName = leftFieldName; this.operand = operand; this.rightTableAlias = rightTableAlias; this.rightFieldName = rightFieldName; }
object IClientCriteriaVisitor <object> .Visit(JoinOperand operand) { Process(operand); if (!ReferenceEquals(operand.AggregatedExpression, null)) { operand.AggregatedExpression.Accept(this); } return(null); }
public virtual CriteriaOperator Visit(JoinOperand theOperand) { CriteriaOperator condition = theOperand.Condition.Accept(this) as CriteriaOperator; CriteriaOperator expression = theOperand.AggregatedExpression.Accept(this) as CriteriaOperator; if (object.ReferenceEquals(condition, null) || object.ReferenceEquals(expression, null)) { return(null); } return(new JoinOperand(theOperand.JoinTypeName, condition, theOperand.AggregateType, expression)); }
protected virtual CriteriaOperator VisitJoin(JoinOperand theOperand) { CriteriaOperator aggregatedExpression = this.AcceptOperator(theOperand.AggregatedExpression); CriteriaOperator condition = this.AcceptOperator(theOperand.Condition); if (object.ReferenceEquals(theOperand.AggregatedExpression, aggregatedExpression) && object.ReferenceEquals(theOperand.Condition, condition)) { return(theOperand); } return(new JoinOperand(theOperand.JoinTypeName, condition, theOperand.AggregateType, aggregatedExpression)); }
private void FreeJoinCompositeCriteria_Execute(object sender, SimpleActionExecuteEventArgs e) { Session session = (this.Application.CreateObjectSpace() as XPObjectSpace).Session; CriteriaOperator joinCriteria = new OperandProperty("^.EmployeeID") == new OperandProperty("EmployeeID"); JoinOperand joinOperand = new JoinOperand("Orders", joinCriteria, Aggregate.Count, new OperandProperty("EmployeeID")); BinaryOperator criteria = new BinaryOperator(joinOperand, new OperandValue(50), BinaryOperatorType.Greater); XPCollection <Employee> employees = new XPCollection <Employee>(session, criteria); }
static void Main(string[] args) { XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString("(local)", "E1883"); CreateData(); // Using constructors CriteriaOperator op1 = new BinaryOperator(CreateExpression("^.Age"), CreateExpression("Age"), BinaryOperatorType.Equal); op1 = new JoinOperand("Person", op1, Aggregate.Max, new OperandProperty("Age")); op1 = new BinaryOperator(op1, new OperandProperty("Age"), BinaryOperatorType.Equal); // Using CriteriaOperator.Parse method CriteriaOperator op2 = CriteriaOperator.Parse("[<Person>][floor(^.Age / 10.0) * 10 = floor(Age / 10.0) * 10].max(Age) = Age"); using (Session session = new Session()) { Console.WriteLine("Testing the CriteriaOperator created using constructors"); using (XPCollection <Person> result1 = new XPCollection <Person>(session, op1, new SortProperty("Name", SortingDirection.Ascending))) { CheckResult(result1); } Console.WriteLine("OK"); Console.WriteLine("Testing the CriteriaOperator created using the CriteriaOperator.Parse method"); using (XPCollection <Person> result2 = new XPCollection <Person>(session, op2, new SortProperty("Name", SortingDirection.Ascending))) { CheckResult(result2); } Console.WriteLine("OK"); Console.WriteLine("Testing the CriteriaOperator created using LINQ to XPO"); // Using LINQ to XPO XPQuery <Person> persons = new XPQuery <Person>(session); var result = from p in persons join pc in persons on Math.Floor(p.Age / 10.0) * 10 equals Math.Floor(pc.Age / 10.0) * 10 into pg where pg.Max(a => a.Age) == p.Age orderby p.Name select p; CheckResult(result.ToList()); Console.WriteLine("OK"); } }
public object Visit(JoinOperand theOperand){ return theOperand; }
public object Visit(JoinOperand theOperand) { if(theOperand.AggregateType == Aggregate.Exists) { return BooleanCriteriaStateObject.Logical; } return BooleanCriteriaStateObject.Value; }
object IClientCriteriaVisitor.Visit(JoinOperand theOperand) { throw new NotImplementedException(FilteringExceptionsText.ExpressionEvaluatorJoinOperandNotSupported); }
string IClientCriteriaVisitor <string> .Visit(JoinOperand theOperand) { throw new NotImplementedException(); }
public virtual object Visit(JoinOperand theOperand) { return null; }
public object Visit(JoinOperand theOperand) { return(theOperand); }
protected virtual void Process(JoinOperand operand) { }
public JoinClause(string leftField, JoinOperand operand, string rightField) { this.leftField = leftField; this.rightField = rightField; this.operand = operand; }
public MainForm() { InitializeComponent(); string tmpString; /* * string * sqlConn = MSSqlConnectionProvider.GetConnectionString("i-nozhenko", "sa", "123", "testdb"); * sqlConn = MSSqlConnectionProvider.GetConnectionString("NOZHENKO-I-XP\\SQLEXPRESS", "testdb"); * * XpoDefault.DataLayer = XpoDefault.GetDataLayer(sqlConn, AutoCreateOption.DatabaseAndSchema); */ /* * Staff * staff = new Staff(XpoDefault.Session) { Name = "Test", Salary = 10, Dep = 1, BirthDate = DateTime.Now, NullField = 123 }; * * staff.Save(); */ XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString("i-nozhenko", "sa", "123", "testdb"); //XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString("NOZHENKO-I-XP\\SQLEXPRESS", "testdb"); Session session = new Session(); #if TEST_QUERY // https://documentation.devexpress.com/#CoreLibraries/CustomDocument4060 // https://www.devexpress.com/Support/Center/Example/Details/E1883 var res = (from master in new XPQuery <TestMaster>(session) join detail in new XPQuery <TestDetail>(session) on master /*.Id*/ equals detail.Master /*.Id*/ where master.Id == 1 select new { Id = master.Id, Name = detail.Name }).ToList(); #endif #if TEST_COMPARER List <Staff> listStaff1 = session.GetObjects(session.GetClassInfo(typeof(Staff)), CriteriaOperator.Parse("Id=?", 1), null, 0, 0, true, true).OfType <Staff>().ToList(), listStaff2 = session.GetObjects(session.GetClassInfo(typeof(Staff)), CriteriaOperator.Parse("Id=?", 1), null, 0, 0, true, true).OfType <Staff>().ToList(); var intersect = listStaff1.Intersect(listStaff2).ToList(); var except = listStaff1.Except(listStaff2).ToList(); var sequenceEqual = listStaff1.SequenceEqual(listStaff2); Session session1 = new Session(), session2 = new Session(); listStaff1 = session1.GetObjects(session1.GetClassInfo(typeof(Staff)), CriteriaOperator.Parse("Id=?", 1), null, 0, 0, true, true).OfType <Staff>().ToList(); listStaff2 = session2.GetObjects(session2.GetClassInfo(typeof(Staff)), CriteriaOperator.Parse("Id=?", 1), null, 0, 0, true, true).OfType <Staff>().ToList(); intersect = listStaff1.Intersect(listStaff2).ToList(); intersect = listStaff1.Intersect(listStaff2, new StaffEqualityComparerById()).ToList(); except = listStaff1.Except(listStaff2).ToList(); except = listStaff1.Except(listStaff2, new StaffEqualityComparerById()).ToList(); sequenceEqual = listStaff1.SequenceEqual(listStaff2, new StaffEqualityComparerById()); #endif session.IdentityMapBehavior = IdentityMapBehavior.Weak; XPClassInfo classInfoMasterDetail = session.GetClassInfo(typeof(TestMaster)); #if TEST_SESSION XPClassInfo classInfoTestDetail = session.GetClassInfo(typeof(TestDetail)); session.ObjectLoaded += session_ObjectLoaded; session.GetObjectsByKey(classInfoTestDetail, new List <object> { 4L, 5L, 6L }, true); TestMaster testMaster = session.GetObjectByKey <TestMaster>(2L, false); if (testMaster != null) { session.PreFetch(new[] { testMaster }, "Details"); foreach (TestDetail testDetail in testMaster.Details) { tmpString = testDetail.Name; } } #endif #if TEST_TABLE_4_TYPES TestTable4Types testTable4Types; #if TEST_VARBINARY byte[] dataI = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7 }, dataII = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; if ((testTable4Types = session.GetObjectByKey <TestTable4Types>(1L, true)) != null) { if (testTable4Types.VarBinary28 == null || testTable4Types.VarBinary28.Length == 0) { testTable4Types.VarBinary28 = dataI; testTable4Types.Save(); } } if ((testTable4Types = session.GetObjectByKey <TestTable4Types>(2L, true)) != null) { if (testTable4Types.VarBinary28 == null || testTable4Types.VarBinary28.Length == 0) { testTable4Types.VarBinary28 = dataI; testTable4Types.Save(); } } if ((testTable4Types = session.GetObjectByKey <TestTable4Types>(3L, true)) != null) { if (testTable4Types.VarBinary28 == null || testTable4Types.VarBinary28.Length == 0) { testTable4Types.VarBinary28 = dataII; testTable4Types.Save(); } } var arrDataI = session.GetObjects(session.GetClassInfo(typeof(TestTable4Types)), new BinaryOperator(new OperandProperty("VarBinary28"), new OperandValue(dataI), BinaryOperatorType.Equal), null, 0, 0, false, true).OfType <TestTable4Types>().ToArray(); var arrDataII = session.GetObjects(session.GetClassInfo(typeof(TestTable4Types)), new BinaryOperator(new OperandProperty("VarBinary28"), new OperandValue(dataII), BinaryOperatorType.Equal), null, 0, 0, false, true).OfType <TestTable4Types>().ToArray(); #endif if ((testTable4Types = session.GetObjectByKey <TestTable4Types>(1L, true)) != null) { tmpString = testTable4Types.Doc.InnerXml; XmlNodeList roots = testTable4Types.Doc.GetElementsByTagName("root"); XmlNode root = roots != null && roots.Count > 0 ? roots[0] : null; if (root != null) { XmlElement newItem = testTable4Types.Doc.CreateElement("item"); XmlAttribute newItemAttribute = testTable4Types.Doc.CreateAttribute("id"); XmlText newItemText = testTable4Types.Doc.CreateTextNode((11 * (root.ChildNodes.Count + 1)).ToString()); newItemAttribute.Value = (root.ChildNodes.Count + 1).ToString(); newItem.Attributes.Append(newItemAttribute); newItem.AppendChild(newItemText); root.AppendChild(newItem); } testTable4Types.Save(); var _root_ = testTable4Types.Doc.SelectNodes("/root"); var __root__ = testTable4Types.Doc.SelectSingleNode("/root"); } #endif Staff staff; XPClassInfo classInfoStaff = session.GetClassInfo(typeof(Staff)), classInfoTestTable4Types = session.GetClassInfo(typeof(TestTable4Types)); XPMemberInfo memberInfoSalary = classInfoStaff.GetPersistentMember("Salary"); if (memberInfoSalary.MemberType.ReflectedType == typeof(XPObjectType)) { tmpString = memberInfoSalary.MemberType.FullName; } ICollection collection; try { collection = session.GetObjectsByKey(classInfoStaff, null, true); } catch (NullReferenceException e) { Console.WriteLine(e.Message); } collection = session.GetObjectsByKey(classInfoStaff, new List <object>(), true); collection = session.GetObjectsByKey(classInfoStaff, new List <object> { 1L }, true); if ((staff = session.FindObject(typeof(Staff), CriteriaOperator.Parse("Id=?", 1)) as Staff) != null) { tmpString = staff.Name; var pName = staff.ClassInfo.FindMember("Name"); if (pName != null) { var name = staff.GetMemberValue("Name"); } var m = staff.ClassInfo.Members.Where(mi => mi.MemberType.FullName == "System.String").Select(mi => mi).ToList(); var cp = staff.ClassInfo.CollectionProperties.Cast <XPMemberInfo>() /*.Where(mi => mi.MemberType.FullName == "System.String")*/.Select(mi => mi).ToList(); var op = staff.ClassInfo.ObjectProperties.Cast <XPMemberInfo>().Where(mi => mi.MemberType.FullName == "System.String").Select(mi => mi).ToList(); var pp = staff.ClassInfo.PersistentProperties.Cast <XPMemberInfo>().Where(mi => mi.MemberType.FullName == "System.String").Select(mi => mi).ToList(); var up = staff.ClassInfo.PersistentProperties.Cast <XPMemberInfo>().FirstOrDefault(mi => mi.Attributes.Any(a => a is UniqueAttribute)); #if TEST_ON_PROPERTY_CHANGED staff.Name = tmpString; #endif } if ((staff = session.FindObject(typeof(Staff), CriteriaOperator.Parse("Id=?", 111)) as Staff) != null) { tmpString = staff.Name; } var _cp_ = classInfoMasterDetail.CollectionProperties; XPServerCollectionSource xpServerCollectionSourceStaff = new XPServerCollectionSource(session, classInfoStaff), xpServerCollectionSourceMasterDetail = new XPServerCollectionSource(session, classInfoMasterDetail); CriteriaOperator joinCriteria = new OperandProperty("^.Master") == new OperandProperty("Id"); JoinOperand joinOperand = new JoinOperand("TestMaster", joinCriteria); XPCollection <TestDetail> s = new XPCollection <TestDetail>(session, joinOperand); /* * select * * from * "dbo"."TestDetail" N0 * where * ( * N0."GCRecord" is null * and exists * ( * select * from "dbo"."TestMaster" N1 where (N1."GCRecord" is null and (N0."IdMaster" = N1."Id")) * ) * ) */ foreach (TestDetail d in s) { } gridControlStaff.DataSource = xpServerCollectionSourceStaff; gridViewStaff.OptionsSelection.MultiSelect = true; gridViewStaff.Appearance.SelectedRow.BackColor = Color.FromArgb(192, 192, 255); gridViewStaff.Appearance.SelectedRow.BackColor2 = Color.Transparent; gridViewStaff.Appearance.SelectedRow.Options.UseBackColor = true; //gridControlStaff.MainView.ExportToXls("test.xls"); //gridControlStaff.MainView.ExportToXlsx("test.xlsx"); gridControlMasterDetail.DataSource = xpServerCollectionSourceMasterDetail; gridControlMasterDetail.ViewRegistered += GridControlMasterDetail_ViewRegistered; gridControlADOdotNETDataTable.DataSource = GetDataTable(); gridControlTestTable4Types.DataSource = new XPCollection(session, typeof(TestTable4Types)); }
public IJoinSourceQueryBuilder <TRecord> On(string leftField, JoinOperand operand, string rightField) { return(On(originalSource.Alias, leftField, operand, rightField)); }
public override Object Visit(JoinOperand operand) { return base.Visit(operand); }
public CriteriaOperator Visit(JoinOperand theOperand) { return(theOperand); }
public static IQueryBuilder <TLeft> On <TLeft>(this IQueryBuilder <TLeft> left, string leftField, JoinOperand operand, string rightField) where TLeft : class { var join = left.QueryGenerator.Joins.Last(); join.On(leftField, operand, rightField); return(left); }
CriteriaOperator IClientCriteriaVisitor <CriteriaOperator> .Visit(JoinOperand theOperand) { return(this.VisitJoin(theOperand)); }
object IClientCriteriaVisitor.Visit(JoinOperand theOperand) { throw new NotImplementedException(); }
CriteriaOperator IClientCriteriaVisitor <CriteriaOperator> .Visit(JoinOperand theOperand) { throw new NotImplementedException(); }
public override void Visit(JoinOperand theOperand) { }
public Join On(string leftField, JoinOperand operand, string rightField) { var joinClause = new JoinClause(leftField, operand, rightField); return(On(joinClause)); }