The EntityManager can pool entities from many models with multiple data sources. The EntityManager is not limited to the entities of one model or one database. A single EntityManager instance can
By default, when DevForce generates the base code for a model, it also code generates a custom EntityManager that contains pre-defined queries for entities in that model (e.g. entityManager.Customers where entityManager = new NorthwindIBEntities()).
However, these pre-defined queries are just for syntactic convenience, and in fact, any EntityManager can query for entities from any model. Instead of using the pre-defined property for the query, you just call GetQuery with the entity type that you want:
C# | manager = new EntityManager(); // Creates an "untyped" EntityManager // - but you can use any EntityManager var query = manager.GetQuery<Customer>(); // "Get all customers" query query.ExecuteAsync(); // listen for completed event and do something |
VB | manager = new EntityManager() ' Creates an "untyped" EntityManager ' - but you can use any EntityManager dim query = manager.GetQuery<Customer>() ' "Get all customers" query query.ExecuteAsync() ' listen for completed event and do something |
The entity types are tied to a particular data source by its DataSourceKey name. The EntityManager and EntityServer learn from the entities they see which data sources are involved in a requested operation.
That model-specificity of entities is apparent in their generated class code; notice the DataSourceKeyName attribute adorning the Customer class:
C# | IbEm.DataSourceKeyName(@"NorthwindEntities")] public partial class Customer : IbEm.Entity {} |
VB | <IbEm.DataSourceKeyName("NorthwindEntities")> Partial Public Class Customer Inherits IbEm.Entity End Class |
DevForce generates a strongly-typed subclass of the EntityManager such as NorthwindIBEntities that appears to be tied to a single model because it has supplemental properties and methods that are specific to one model. Managers are typically used with one model and these extra member make it convenient to work with that model. But, like every EntityManager, the derived manager can contain entities from multiple models, query from multiple models, and save to multiple databases.