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.Xpo DevExpress.Xpo 18.1 to 23.2 ✔️

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.Xpo.XPQuery.XPQuery
DevExpress.Xpo.XPCollection.XPCollection
DevExpress.Xpo.XPQueryExtensions.Query
DevExpress.Xpo.XPBaseObject.Save
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

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);
            }
        }     
    }
}

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;

        }
    }
}

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);
    }
  }
}