Click or drag to resize

Introduction to base library concepts

The Aloe.SystemFrameworks.Domain is an ORM library intended to simplify the creation of domain specific libraries.

Although it is a general-purpose library, its primary target is the EnterpriseOne Object Library and hence it supports mainly the requirements of this library.

The library has some limitations, including:

  • Only Guids are supported as primary keys

  • Only a limited LINQ subset is supported - SELECT, FROM, WHERE and Take()

  • Queries support only AND operator for WHERE clauses

  • Skip() is currently not supported (although there are plans for it)

The primary benefits of the library are:

  • Can be used for both server (mid-tier) and client (presentation) objects

  • Can handle very large domains with plenty of references

  • Includes object oriented object-relational mapping, which is very extensible

  • Supports most basic concepts like unit of work, validation, lazy loading, ghost objects, etc.

  • Is very easy to extend

The classes in the library are presented in the namespace Aloe.SystemFrameworks.Domain presentation

You should also check some basic concepts, which are included in the see also section.

Example code, using the library:

EnterpriseOneDataSource ds = new EnterpriseOneDataSource(serverAddress, securityInfo);
EnterpriseOneRepositorySource rs = new EnterpriseOneRepositorySource(ds);
using (var tr = new ObjectTransaction(rs))
{
  //create new Customer and add it to the transactions change set
  Customer c = new Customer(tr) { Number = "3", CreditLimit = 10000 };
  c.Active = true;
  c.Add();

  //get specific customer from the data source
  var c2 = tr.Get<Customer>(Guid.Parse("00f6eb9e-74fe-e111-82b1-00155d001f00"));

  //cycle through the specific prices for this customer
  foreach(ProductPrice pp in c2.ProductPrices)
  {
    Console.WriteLine(pp.Price);
  }

  //use LINQ
  var query1 = 
    from cust in tr.Query<Customer>()
    where cust.CreditLimit > 1000
    select cust;
  foreach(var cust in query1)
  {
    Console.WriteLine(cust.Number);
  }

  //you cannot use projection directly, but it is allowed after enumerating
  var query1a = query1.ToList().Select(cust=> new { cust.Id, cust.Number });

  //return the top 3 customers, whose Numer contains 106. Use short LINQ
  var query2 = tr.Query<Customer>().Where(cust => cust.Number.Like("%106%")).Take(3);

  //Same as above, but with normal LINQ. Notice, that .Take() does not have LINQ language construct
  //and is added directly in the foreach statement. Still it effects the query directly,
  //because the query is executed on enumeration
  var query3 = from cust in tr.Query<Customer>()
               where cust.Number.Like("%106%")
               select cust;
  foreach(var cust in query3.Take(3))
  {
    Console.WriteLine(cust.Number);
  }

  //get all customers to a list
  var query4 = tr.Query<Customer>().ToList();

  //retrieve the first 2 unique customer types from the above list. This is IEnumerable processing
  var query5 = (from cust in query4
                where cust.CustomerType != null
                select cust.CustomerType).Distinct().Take(2);

  //use .In to retrieve customers, whose type is from the list
  var query6 = from cust in tr.Query<Customer>()
               where cust.CustomerType.In(query5)
               select cust;

    //commit the transaction
    tr.Commit();
  }
See Also