Highlighted
Super Contributor.
Super Contributor.
2119 views

Using DevExpress attributes

Jump to solution

I've uploaded a simple c# project which uses a persistent object class and DevExpress XPO (xpress persistent objects) to bind a SQLite database table (called trans_item) to a DevExpress GridControl.  I have also uploaded a Visual COBOL project which tries to do the same thing.  I am trying to translate the c# persistent object class (trans_item) into Visual COBOL.  The problem I am having is in defining the attributes.  There are three DevExpress attributes I need to set.  I have looked at the Visual COBOL documentation on attributes and also at the the CustomAttributes solution under Micro focus Visual COBOL Samples.  The c# project works.  There is something wrong with how I am defining the attributes in Visual COBOL.  The editor gives an error of "incorrect program structure" for the first instance of "attribute" in the code.

The c# class looks like this:

using DevExpress.Xpo;

namespace CsSQLite
{
    public class trans_item :XPBaseObject {

        public trans_item() { }
        public trans_item(Session session) :
            base(session) {
        }

        [Key(AutoGenerate = false), Persistent("trans_item_id")]
        int ftrans_item_id = -1;

        [PersistentAlias("ftrans_item_id")]
        public int trans_item_id
        {
            get { return ftrans_item_id; }
        }


The Visual COBOL class is coded like this:

     class-id AM_420_PayeeActivity.trans_item inherits type XPBaseObject.
       
       working-storage section.

         01  ftrans_item_id            binary-long value -1.
         
       method-id NEW Public.
       procedure division.
           goback.
       end method.

       method-id NEW Public.
       procedure division using session as type Session.
           invoke super::new(session)
           goback.
       end method.
       
       attribute Key(AutoGenerate = false) Persistent("trans_item_id")
       
       attribute PersistentAlias("ftrans_item_id")
       property-id  trans_item_id binary-long public.
       getter.
         set property-value to ftrans_item_id
       end property.

Phil Levin

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using DevExpress attributes

Jump to solution

Hi Phil,

The attributes should be defined as part of the field, property or method definition.
Please see the C#-->COBOL comparison examples in the docs under General Reference-->Managed COBOL-->Comparison of COBOL with other managed languages-->Attributes.

Example:

        working-storage section.
        01  areaCode                  string private.
        01  acctName                  string private.
        01  ftrans_item_id            binary-long value -1
              attribute Key("AutoGenerate" = false)
              attribute Persistent("trans_item_id").
      method-id NEW Public.
      procedure division.
          goback.
      end method.

      method-id NEW Public.
      procedure division using session as type Session.
          invoke super::new(session)
          goback.
      end method.

      property-id  trans_item_id binary-long public
          attribute PersistentAlias("ftrans_item_id").
      getter.
        set property-value to ftrans_item_id
      end property.

View solution in original post

0 Likes
5 Replies
Highlighted
Super Contributor.
Super Contributor.

RE: Using DevExpress attributes

Jump to solution

The c# project was too large to upload (greater than 64 kb) so I've only uploaded the Visual COBOL project.

Phil Levin

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Using DevExpress attributes

Jump to solution

I've made this correction but still get the error:

      attribute Key(property AutoGenerate = false) Persistent("trans_item_id")

Phil Levin

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Using DevExpress attributes

Jump to solution

https://www.dropbox.com/s/h5iqpt4wi792aly/CsSQLite.zip

This is a link to the c# project.

Phil Levin

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Using DevExpress attributes

Jump to solution

Hi Phil,

The attributes should be defined as part of the field, property or method definition.
Please see the C#-->COBOL comparison examples in the docs under General Reference-->Managed COBOL-->Comparison of COBOL with other managed languages-->Attributes.

Example:

        working-storage section.
        01  areaCode                  string private.
        01  acctName                  string private.
        01  ftrans_item_id            binary-long value -1
              attribute Key("AutoGenerate" = false)
              attribute Persistent("trans_item_id").
      method-id NEW Public.
      procedure division.
          goback.
      end method.

      method-id NEW Public.
      procedure division using session as type Session.
          invoke super::new(session)
          goback.
      end method.

      property-id  trans_item_id binary-long public
          attribute PersistentAlias("ftrans_item_id").
      getter.
        set property-value to ftrans_item_id
      end property.

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Using DevExpress attributes

Jump to solution

Thanks.  It works well now.  It takes 1 second to load the grid with 30,000 records.

Phil Levin

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.