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, Please do not ask but we separated our tables in a GENERAL schema and Domain specific Schema. We also have a few foreign key constraints across the schemas as well. E.g. we have a table in the domain called MP_STATIC which has an Id primary key. In the same schema we have a linking table called MP_STATIC_CUSTOMER which has a foreign key to MP_STATIC.MP_STATIC_ID and a foreign key to the CUSTOMER.CUSTOMER_ID column in the GENERAL schema. So we have 2 separate LS models, how would you implement the code to find the customer for our MP_STATIC record?
|
|
|
A LightSpeed model can include entities from more than one schema, by specifying TableAttribute in the code or by setting the Schema for each entity in the designer. So our recommendation would be to create a single LightSpeed model containing all the entities you need, and use the schema setting to handle the multiple schemas. If you really want to keep two separate models as well as two separate database schemas then you will have a bit of manual work to do to bridge across them -- specifically you will not be able to set up associations in the designer, but will instead have to create these in code via partial classes, and if you want to use the LINQ wrapper classes then you will have to write a small amount of bridging code. We can provide guidance on this if required. Note you will still need to specify per-entity schemas in this case because otherwise LightSpeed will use the connection (unit of work/LightSpeedContext) default schema for all entities. |
|
|
Thanks for the quick reply Ivan. I will try this out. |
|
|
By the way this worked like a charm, thx! |
|
|
Hi Ivan, I have a similar problem, but my problem is that using LS 2.2, the relationship between tables in different schemas is not shown. Let me better explain... We have to manage a company schema (MAN) where we can create tables, views, etc. and where company data can be entered, modified or deleted. The other schema (FIS), is a legacy schema where data are loaded using procedures prepared by the external softwarehouse that owns the centralized datawarehouse, in this schema there are the master tables. What I did was to create constraints between some MAN schema tables and the FIS schema master tables. This to prevent the user to insert in the MAN tables items that don't exist in the master tables. The problem is that, if a foreign key is setted between a table in the MAN schema and a table in the FIS schema, the relationship is not shown in the designer and the respective collection is not created. What do you suggest to do in this case? Thanks in advance for your help CreF |
|
|
Hello CreF, I'd suggest just adding the relationship manually from the Toolbox (click on OneToManyAssociation and drag from the parent table to the child). You may need to fix up things like column names by hand after doing this (click on the arrow that you've just drawn and review its properties in the Properties window). I've logged a bug for this and we'll see if we can get it fixed in a future release (but this will be a future release of 3, not a 2.2 nightly). |
|