DevExpress XPO - 1.0

Extension ID

com.castsoftware.dotnet.devexpress.xpo

What’s new?

Please see DevExpress XPO - 1.0 - Release Notes for more information.

Description

This extension provides support for the DexExpress XPO persistence framework for .NET.

In what situation should you install this extension?

This extension should be installed when analyzing a .NET project that uses DexExpress XPO persistence framework, and you want to view CRUD transactions of the XPO persistent objects. Links to corresponding SQL database tables can also be resolved, provided that the SQL database has been extracted and DDL has been created.

Technology support

The following libraries are supported by this extension:

Language Library name Namespace Version Supported
.NET DevExpress.Xpoexternal link DevExpress.Xpo
DevExpress.Xpo.DB
18.1 to 23.2 ✔️
.NET DevExpress.ExpressAppexternal link DevExpress.ExpressApp 24.1.4 ✔️

Compatibility 

This extension is compatible with:

CAST Imaging Core release Supported
8.3.x ✔️

Download and installation instructions

For applications using any of the above mentionned libraries, this extension will be automatically installed by CAST Imaging Console. For upgrade, if the Extension Strategy is not set to Auto update, you can manually upgrade the extension using the Application - Extensions interface.

What results can you expect?

Once the analysis/snapshot generation has completed, you can view the below objects and links created.

Objects

Icon Description Comment
entity_icon DevExpress XPO Entity An object is created for each XPO Persistent Object
entity_operation DevExpress XPO Entity Operation An object is created for each XPO Persistent Object CRUD operation
unknown_entity_icon DevExpress XPO Unknown Entity An object is created for when XPO Persistent Object cannot be resolved
unknown_entity_operation DevExpress XPO Unknown Entity Operation An object is created for each XPO Persistent Object CRUD operation and respective Entity cannot be resolved
sql_query_icon DevExpress XPO SQL Query An object is created for each direct SQL query operation found in XPO project and resolved in a method call
unknown_sql_query_icon DevExpress XPO Unknown SQL Query An object is created for each direct SQL query found in XPO project and the exact query cannot be resolved
Link Type Caller Callee APIs Supported
callLink C# Method DevExpress XPO Entity Operation
DevExpress XPO Unknown Entity Operation
DevExpress.Xpo.Session APIsDevExpress.Xpo.Session.BulkLoad
DevExpress.Xpo.Session.BulkLoadAsync
DevExpress.Xpo.Session.Delete
DevExpress.Xpo.Session.FindObject
DevExpress.Xpo.Session.CollectReferencingObjects
DevExpress.Xpo.Session.DeleteAsync
DevExpress.Xpo.Session.DeleteCore
DevExpress.Xpo.Session.DeleteCoreAsync
DevExpress.Xpo.Session.DeleteObject
DevExpress.Xpo.Session.DeleteObjectAsync
DevExpress.Xpo.Session.DeleteObjectOrCollection
DevExpress.Xpo.Session.DeleteObjectOrCollectionAsync
DevExpress.Xpo.Session.FindObjectAsync
DevExpress.Xpo.Session.FindObjectAsyncResultProcess
DevExpress.Xpo.Session.GetLoadedObjectByKey
DevExpress.Xpo.Session.GetObjectByKey
DevExpress.Xpo.Session.GetObjectByKeyAsync
DevExpress.Xpo.Session.GetObjects
DevExpress.Xpo.Session.GetObjectsAsync
DevExpress.Xpo.Session.GetObjectsByKey
DevExpress.Xpo.Session.GetObjectsByKeyAsync
DevExpress.Xpo.Session.Reload
DevExpress.Xpo.Session.Save
DevExpress.Xpo.Session.ReloadAsync
DevExpress.Xpo.Session.SaveAsync
DevExpress.Xpo.Session.SelectData
DevExpress.Xpo.Session.SelectDataAsync
DevExpress.ExpressApp APIs DevExpress.ExpressApp.IObjectSpace.CreateCollection
DevExpress.ExpressApp.IObjectSpace.CreateObject
DevExpress.ExpressApp.IObjectSpace.Delete
DevExpress.ExpressApp.IObjectSpace.FindObject
DevExpress.ExpressApp.IObjectSpace.FirstOrDefault
DevExpress.ExpressApp.IObjectSpace.GetObject
DevExpress.ExpressApp.IObjectSpace.GetObjectByKey
DevExpress.ExpressApp.IObjectSpace.GetObjects
DevExpress.ExpressApp.IObjectSpace.GetObjectsCount
DevExpress.ExpressApp.IObjectSpace.GetObjectsQuery
DevExpress.ExpressApp.IObjectSpace.ReloadObject
DevExpress.ExpressApp.IObjectSpaceAsync.FindObjectAsync
DevExpress.ExpressApp.IObjectSpaceAsync.GetObjectAsync
DevExpress.ExpressApp.IObjectSpaceAsync.GetObjectByKeyAsync
DevExpress.ExpressApp.IObjectSpaceAsync.LoadAsync
DevExpress.ExpressApp.IObjectSpaceAsync.ReloadObjectAsync
DevExpress.Xpo.XPQuery.XPQuery
DevExpress.Xpo.XPCollection.XPCollection
DevExpress.Xpo.XPQueryExtensions.Query
DevExpress.Xpo.XPBaseObject.Save
DevExpress.Xpo.DB.IDataStore.ModifyData
DevExpress.Xpo.IDataLayer.ModifyData
DevExpress.Xpo.DB.ConnectionProviderSql.ModifyData
DevExpress.Xpo.DB.DataStoreSerializedBase.ModifyData
DevExpress.Xpo.DB.IDataStore.SelectData
DevExpress.Xpo.IDataLayer.SelectData
DevExpress.Xpo.DB.ConnectionProviderSql.SelectData
DevExpress.Xpo.DB.DataStoreSerializedBase.SelectData
callLink C# Method DevExpress XPO SQL Query
DevExpress XPO Unknown SQL Query
DevExpress.Xpo.Session APIsDevExpress.Xpo.Session.GetObjectsByKeyFromQuery
DevExpress.Xpo.Session.GetObjectsByKeyFromSproc
DevExpress.Xpo.Session.GetObjectsFromQuery
DevExpress.Xpo.Session.GetObjectsFromSproc
DevExpress.Xpo.Session.GetObjectsFromSprocAsync
DevExpress.Xpo.Session.GetObjectsFromSprocParametrized
DevExpress.Xpo.Session.GetObjectsFromSprocParametrizedAsync
DevExpress.Xpo.Session.ExecuteNonQuery
DevExpress.Xpo.Session.ExecuteNonQueryAsync
DevExpress.Xpo.Session.ExecuteQuery
DevExpress.Xpo.Session.ExecuteQueryAsync
DevExpress.Xpo.Session.ExecuteQueryWithMetadata
DevExpress.Xpo.Session.ExecuteQueryWithMetadataAsync
DevExpress.Xpo.Session.ExecuteScalar
DevExpress.Xpo.Session.ExecuteScalarAsync
DevExpress.Xpo.Session.ExecuteSproc
DevExpress.Xpo.Session.ExecuteSprocAsync
DevExpress.Xpo.Session.ExecuteSprocParametrized
DevExpress.Xpo.Session.ExecuteSprocParametrizedAsync
useLink DevExpress XPO Entity Operation Table, View Created by SQLAnalyzer when DDL source files are analyzed
callLink DevExpress XPO Entity Operation Procedure Created by SQLAnalyzer when DDL source files are analyzed
useLink DevExpress XPO SQL Query Table, View Created by SQLAnalyzer when DDL source files are analyzed
callLink DevExpress XPO SQL Query Procedure Created by SQLAnalyzer when DDL source files are analyzed

Examples

XPO Persistent Objects CRUD

using DevExpress.Xpo;

namespace DevExpress.Xpo.ConsoleCoreDemo {
    class StatisticInfo : XPLiteObject {
        public StatisticInfo(Session session)
            : base(session) {
        }
        Guid key;
        [Key(true)]
        public Guid Key {
            get { return key; }
            set { SetPropertyValue(nameof(Key), ref key, value); }
        }
        string info;
        [Size(255)]
        public string Info {
            get { return info; }
            set { SetPropertyValue(nameof(Info), ref info, value); }
        }
        DateTime date;
        public DateTime Date {
            get { return date; }
            set { SetPropertyValue(nameof(Date), ref date, value); }
        }
    }
}
DevExpress.Xpo.XPBaseObject.Save
using DevExpress.Xpo;
using DevExpress.Xpo.DB;

namespace DevExpress.Xpo.ConsoleCoreDemo {
    class Program {
        static void Main(string[] args) {
                    
        using(UnitOfWork uow = new UnitOfWork()) {
                StatisticInfo newInfo = new StatisticInfo(uow);
                newInfo.Info = result;
                newInfo.Date = DateTime.Now;
                newInfo.Save();
                Console.WriteLine("Saved.");
            }
        }
    }
}

DevExpress.Xpo.XPQueryExtensions.Query
namespace DevExpress.Xpo.ConsoleCoreDemo {
    class Program {
        static void Main(string[] args) {

        using(UnitOfWork uow = new UnitOfWork()) {
                var query = uow.Query<StatisticInfo>()
                    .OrderBy(info => info.Date)
                    .Select(info => $"[{info.Date}] {info.Info}");
                foreach(var line in query) {
                    Console.WriteLine(line);
            }
        }     
    }
}

DevExpress.ExpressApp APIs

DevExpress.ExpressApp.IObjectSpace.GetObject
using DevExpress.Xpo;

public partial class rec_DocSrv_Order_Detail : XPLiteObject
{
    int fdocsrv_order_detail;
    [Key(true)]
    [DevExpress.Xpo.DisplayName(@"ID")]
    public int docsrv_order_detail
    {
        get { return fdocsrv_order_detail; }
        set { SetPropertyValue<int>("docsrv_order_detail", ref fdocsrv_order_detail, value); }
    }
    rec_DocSrv_Order fdocsrv_order_id;
}

[DefaultClassOptions]
[NavigationItem("Document Service")]
[DevExpress.ExpressApp.DC.XafDisplayName("Document Service Order Detail")]
[DevExpress.Persistent.Base.ImageName("rec_DocSrv_Order_Detail")]
[DevExpress.ExpressApp.DC.XafDefaultProperty("rec_doc_info_id")]
public partial class rec_DocSrv_Order_Detail
{
    public rec_DocSrv_Order_Detail(Session session) : base(session){ }
}
using DevExpress.ExpressApp;

private void act_Delivered_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(rec_DocSrv_Order_Detail));
            DateTime serviceDateTime = Core.SqlOp.GetServerDateTime(objectSpace);
            foreach (rec_DocSrv_Order_Detail item in e.SelectedObjects)
            {
                rec_DocSrv_Order_Detail detail = objectSpace.GetObject(item);
                detail.delivered = true;
                detail.delivered_date = serviceDateTime;
            }
            objectSpace.CommitChanges();
            ObjectSpace.Refresh();
        }

DevExpress.ExpressApp.IObjectSpace.CreateObject
using DevExpress.Xpo;

public partial class rec_Applicant : XPLiteObject
    {
        string fapplicant_address;

        [Size(255)]
        DateTime fapplicant_birth_date;
    }

public partial class rec_Applicant
    {
        public rec_Applicant(Session session) : base(session) { }
        public override void AfterConstruction() { base.AfterConstruction(); }
    }
using DevExpress.ExpressApp;

private void actionTransferApplicant_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            var selectedItems = e.SelectedObjects;
            if (selectedItems.Count == 0)
                return;

            IObjectSpace objectSpace = Application.CreateObjectSpace();

            foreach (rec_job_post_apply apply in selectedItems)
            {
                rec_Applicant applicant = objectSpace.CreateObject<rec_Applicant>();
                applicant.applicant_name = apply.apply_name;
            }
            objectSpace.CommitChanges();
            View.ObjectSpace.Refresh();
        }

XPCollection

using DevExpress.Xpo.DB;
using DevExpress.Xpo.Metadata;

namespace dxTestSolutionXPO {
    class Program {
        static void Main(string[] args) {
            ConnectionHelper.Connect(DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            MakeInitialData();
            var session = new Session();
            var lst = new XPCollection<OrderItem>(session);
            var cnt = lst.Count;
            var c = new XPCollection<Order>(session)[0].OrderItems.ToList();
        }

        static T CreateObject<T>(string propertyName, string value, Session session) {

            T theObject = session.FindObject<T>(new OperandProperty(propertyName) == value);
            if (theObject == null) {
                theObject = (T)Activator.CreateInstance(typeof(T), new object[] { session });
                ((XPCustomObject)(object)theObject).SetMemberValue(propertyName, value);
            }

            return theObject;

        }
    }
}
XPCollection<Order>

XPCollection<OrderItem>

Unknown XPO Persistent Object

Direct SQL Query

DevExpress.Xpo.Session.ExecuteQueryWithMetadata
namespace WpfApplication1
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Windows;

  using DevExpress.Xpo;
  using DevExpress.Xpo.DB;


  public class DataSource
  {
    public DataSource()
    {
      Setup();
    }

    public XPDataView Data { get; private set; }

    private void Setup()
    {
      var connectionString = MSSqlConnectionProvider.GetConnectionString("sever", "user", "passwd", "database");
      var dataLayer        = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.SchemaAlreadyExists);

      using (var uow = new UnitOfWork(dataLayer))
      {
        var sql    = "SELECT Id, Name FROM customer WHERE Name = @Name";
        var dbData = uow.ExecuteQueryWithMetadata(sql, new[] { "Name" }, new[] { "Computer" });

        Data = new XPDataView().FillAndLoad(dbData.ResultSet);
      }
    }
  }
}

Unknown Direct SQL Query

namespace WpfApplication1
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Windows;

  using DevExpress.Xpo;
  using DevExpress.Xpo.DB;

  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      DataContext = new DataSource();
    }
  }

  public class DataSource
  {
    public DataSource()
    {
      Setup();
    }

    public static XPDataView FillAndLoad(this XPDataView self, Session sess, string sql)
    {
      return self.FillAndLoad(sess.ExecuteQueryWithMetadata(sql).ResultSet);
    }
  }
}