XPO Fields

This feature is helpful for those who work with eXpress Persistent Objects. XPO Fields works in the PersistentBase descendants, where it automatically generates and maintains the XPO entities in Simplified Criteria Syntax based on the class members.

Follow the steps below to learn how to use this feature:

  • Create a PersistentBase descendant.

    class MyPersistentClass: PersistentBase {
        protected MyPersistentClass(Session session) : base(session) { }
    
    }
    
  • Add the required fields and properties.

    public struct Occupation {
        public string Position;
        public string Team;
    }
    class MyPersistentClass: PersistentBase {
        protected MyPersistentClass(Session session) : base(session) { }
        public int age;
        public int Name { get; set; }
        public Occupation occupation;
        [NonPersistent]
        public bool Active { get; set; }
    }
    
  • Place the caret on the class name (MyPersistentClass in this case).
  • Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  • Select Update XPO Fields Class. This will generate or update the new FieldsClass inside the current class. The members with the [NonPersistent] attribute are not included in the FieldsClass class.

    class MyPersistentClass: PersistentBase {
        protected MyPersistentClass(Session session) : base(session) { }
        public int age;
        public int Name { get; set; }
        public Occupation occupation;
        [NonPersistent]
        public bool Active { get; set; }
    
        // Created/Updated: TestUser on TestPC at 6/14/17 8:20 PM
        public new class FieldsClass : PersistentBase.FieldsClass {
            public FieldsClass() { }
            public FieldsClass(string propertyName) : base(propertyName) { }
            public OperandProperty age {
                get { return new OperandProperty(GetNestedName("age")); }
            }
            public OperandProperty Name {
                get { return new OperandProperty(GetNestedName("Name")); }
            }
            public OperandProperty occupation_Position {
                get { return new OperandProperty(GetNestedName("occupation.Position")); }
            }
            public OperandProperty occupation_Team {
                get { return new OperandProperty(GetNestedName("occupation.Team")); }
            }
            public OperandProperty occupation {
                get { return new OperandProperty(GetNestedName("occupation")); }
            }
        }
        public new static FieldsClass Fields {
            get {
                if (ReferenceEquals(_Fields, null))
                    _Fields = new FieldsClass();
                return _Fields;
            }
        }
        static FieldsClass _Fields;
    }
    

You can configure different options of FieldsClass generation on the Editor | All Languages | Code Actions | Update XPO Fields Class options page.

CodeActions_XPOFields