This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I am doing some proof of concept tests to see if lightspeed is right for us. My major concern is if it will play nice when my domain model is spread across multiple database platforms (SQL Server, Oracle, & MySQL). In my test code I have a class called 'LabRequest' which has a member class called 'Customer' & vica-versa. (n-to-1 relationship from 'LabRequest' to 'Customer' and 1-to-n from 'Customer' to 'LabRequest') My issue is that 'LabRequest' sits in SQL db and 'Customer' is in Oracle. How can I instruct LightSpeed to automatically load each class and it's member from their respective databases. Here's some code below: My ‘Customer’ Class: namespace ClassLibrary2 { [Table("CUSTOMERS", IdColumnName = "CUSTOMER_NUMBER")] public class Customer : Entity<int> { #region PrivateFields [Column("COMPANY_CODE")] private string _COMPANY_CODE; [Column("Customer_Number")] private int _customerId; [Column("Customer_Name")] private string _Customer_Name; #endregion #region Properties public string CompanyCode { get { return _COMPANY_CODE; } set { Set(ref _COMPANY_CODE, value); } } public int CustomerNumberID { get { return _customerId; } set { Set(ref _customerId, value); } } public string CustomerName { get { return _Customer_Name; } set { Set(ref _Customer_Name, value); } } #endregion #region Associations public readonly EntityCollection<LabRequest> _labrequests = new EntityCollection<LabRequest>(); public EntityCollection<LabRequest> LabRequests { get { return Get(_labrequests); } } #endregion } } My ‘LabRequest’ Class: namespace ClassLibrary2 { [Table(IdColumnName = "LRID")] public class LabRequest : Entity<int> { #region PrivateFields private int _LRNumber; private string _Division; #endregion #region Properites public int LRNumber { get { return _LRNumber; } set { Set(ref _LRNumber, value); } } public string Division { get { return _Division; } set { Set(ref _Division, value); } } #endregion #region Associations [ReverseAssociation("LabRequests")] public EntityHolder<Customer> _customer = new EntityHolder<Customer>(); public Customer Customer { get { return Get(_customer); } set { Set(_customer, value); } } [Column("Customer_Number")] private int _customerId; public int CustomerID { get { return _customerId; } set { Set(ref _customerId, value); } } #endregion } } My Test Page: public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var EUcontext = new LightSpeedContext("EU_context"); EUcontext.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EnterpriseUsersDB"].ToString(); using (var unitOfWork = EUcontext.CreateUnitOfWork()) { var lr = unitOfWork.FindById<LabRequest>(4); Response.Write(lr.CustomerID); } } } The test page above loads properly but when it tries to get the member class ‘Customer’ it gets error “Message = "Invalid object name 'CUSTOMERS'."” since it is looking for the wrong table in the wrong database. What is the best approach when working with such an architecture? I’m thinking lazy loading will be helpful here.. any thoughts and suggestions will be appreciated. Thanks. |
|