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
|
Greetings. I am new to LightSpeed and am loving it immensely! Amazing product and such great support. So far selects and updates are working perfectly in the model. Inserts are having problems now. Here is kind of a log of a few changes I have made and the generated SQL by LightSpeed where applicable. I shall be so very appreciative for your help! Thank you so kindly. Agraha Situation 1 As you can tell, I am trying many items, but not sure how to handle this so it compiles and does correct insertions! Thank you again! |
|
|
|
|
Hello Agraha, I'm not sure what error you're seeing in your Situations 1 and 2, but it sounds like there's some sort of capitalisation issue that is making Oracle unable to recognise the NMS_MAIN_Id column, is that right? By default Oracle column names are not case-sensitive, but I believe there is an option when creating an Oracle table to make it case-sensitive. It sounds like that option may be set on your table. If so, you need to do two things on the LightSpeed side: 1. Set LightSpeedContext.QuoteIdentifiers to true. This causes LightSpeed to quote all names, which is required in Oracle to preserve their case (as I understand it). 2. Where the property and column casing don't match, add Column Name settings (or ColumnAttribute if writing the model by hand) to force correct casing. 3. Set Identity Column Name (or TableAttribute.IdColumnName if writing the model by hand), again using the casing from the database. Regarding your situation 4, if you change the backreference name, this gets used with an Id suffix as the foreign key column name. E.g. if the backreference is named Parent, LightSpeed will look for a foreign key column named ParentId. To change the foreign key column name, set the Backreference Id Column Name of the association -- this overrides the default XxxId column name. (The FK *property* in LightSpeed will still be called XxxId, but it will be mapped to a different column in the database.) If none of this helps then could you post a *minimal* model (just one or two tables) and table definitions (CREATE TABLE scripts) that reproduce this problem and we will look into it for you. |
|
|
|
|
Thank you so much for your quick reply, Ivan. I know it seems that the Oracle column names are acting as if they are case-sensitive, but they are not. I am having problems only with the Identity Column Name setting. All the rest of the mappings for all the fields, including for the actual identity fields, NMS_DS_ID and NMS_MAIN_ID, are mapping just fine, using the settings as read by MindScape's visual interface for the LightSpeed model inside Visual Studio. However, if I do not change the Identity Column Names from NMS_DS_ID to Nms_Ds_Id and from NMS_MAIN_ID to Nms_Main_Id, I get this error: Unable to materialize field [NmsStatusId] on type [NAL.Model.NmsDs]. Check your table has an Id column and that your mappings are correct. See inner exception for details. In fact, that is why I changed the setting of the Identity Column Names in the first place to Nms_Ds_Id and Nms_Main_Id. Then the errors go away and all works for selects, updates and deletes--but not for inserts. The same happens when I go into the Model.cs code and change what works for all but inserts. So this works for all but inserts: [Table("NMS_MAIN", IdColumnName="Nms_Main_Id", Schema="SUPPLYCHAIN")] This gives me the run-time error when I try to run the applicaiton: [Table("NMS_MAIN", IdColumnName="NMS_MAIN_ID", Schema="SUPPLYCHAIN")]
Here are a couple table definitions from the Oracle database. I hope it well be helpful! I am not certain if you wanted a little more, as far as the model, so I am also attaching what has been generated from LightSpeed's visual interface modeler for the same two tables. I apologise in advance for all the code!!! I hope this is what you are requesting me to send. I appreciate your product and your help immensely, Ivan. Agraha --****ddl for nms_main CREATE TABLE nms_main ALTER TABLE nms_main -- Foreign Key
--****ddl for nms_ds CREATE TABLE nms_ds ***************************************************************** Generated code inside Visual Studio for NMS_MAIN object [Serializable]
Generated code inside Visual Studio for NMS_DS object: [Serializable]
|
|
|
|
|
Okay, I think I see the problem: [quote user="Agraha"] [Table("NMS_MAIN", IdColumnName="Nms_Main_Id", Schema="SUPPLYCHAIN")] [/quote] This causes both the Id property (implicit in Entity base class) and the _nmsMainId field (aka the NmsMainId property) to back onto the same column (NMS_MAIN_ID), and LightSpeed gets confused. What you need to do is delete the NmsMainId property from your entity model. You don't need it because the ID is available through the Id property. (The Id property isn't shown in the model because it's inherent in the fact of being a LightSpeed entity: it's declared on the Entity<TId> base class.) Once you've done that, only the Id will be mapped to the NMS_MAIN_ID column, and the problems caused by the duplicate mapping should go away. It looks like you'll have similar issues with other entities in your model e.g. the NmsDs class has a duplicate mapping via its NmsDsId property. You'll have to delete these properties in those other entities as well. Normally the designer should figure out that NMS_MAIN_ID (etc.) was the primary key column and not create a NmsMainId property (only the Identity Column Name override), so this error wouldn't occur, but it's possible something went awry in this case. |
|
|
|
|
Greetings, Ivan! It is working just perfectly now. Thank you a million times. Agraha |
|
|
|