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
|
Good Day, I am new to Lightspeed and I am experiencing an issue only with certain tables. I think the issue is related to how lightspeed is camel casing the column names when mapping to properties as the code is being generated. I have the latest build from 9/27/2012. For example, I have a table with a Column "EMP" which gets generated as "Emp" and while there are no Build errors, there are runtime SQL exceptions stating: "Invalid column name: "Emp". Another example is "ItemSKUNumber" becomes "ItemSkuNumber", which is also invalid within the same table at runtime. I read in the forums that I can customize my code generation template and I can see in FieldProperties.vm where the CamelCase method is called, but I am unsure how I should modify this file to address this issue. In essence, I want the table column name and property to match, with the private members to just be _ Thank you and have a good day, Albert |
|
|
Hi Albert, Check that the "Column Name" property has been assigned the value of the actual column name in SQL by inspecting the properties for the Entity Property in the designer. Column Name is used to map from the name of the field we generate to the underlying SQL column name when creating queries. Did you create these tables by dragging them on from the server explorer? If so the column name property should be being assigned automatically - let us know if this does not appear to be the case!
|
|
|
Good Day Jeremy, Yes, I just did a simple drag and drop from the server explorer. Here is a sql generated create script for an example table. CREATE TABLE [dbo].[_acAddOnItemDeletes2](
ID int IDENTITY(1,1), After I drag and drop. MiscID becomes MiscId and generates the runtime error mentioned before, the same with SOLineItemKey which becomes SoLineItemKey. Here is the class that LS generates. using System; using Mindscape.LightSpeed; using Mindscape.LightSpeed.Validation; using Mindscape.LightSpeed.Linq; namespace LSObjects
{
[Serializable]
[System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
[System.ComponentModel.DataObject]
public partial class _acAddOnItemDeletes2 : Entity
} ///
} } Just create a context and try to access that objects in that entity, and it will error out at runtime, but the compiler sees it just fine. Thank you for your time, I hope this helps, Albert |
|
|
Thanks for the extra detail - which database provider are you targetting?
|
|
|
MS SQL Server 2008 R2. Thank you, -- Albert |
|
|
Do you have a setting forcing case sensitivity? e.g. Presumably if you load up Management Studio and issue an adhoc query like this then it will fail?
|
|
|
yes sir. We do have case sensitivity. Albert |
|
|
That query will fail in management studio for us. |
|
|
Thanks for the clarification. Unfortunately for now you will need to manually set the column name for each column where this is an issue as our schema extractor is not detecting for this case.
|
|
|
Thank you Jeremy for your help. So there is no way to use the existing code templates to workaround this issue? Potentially there could be hundreds of tables in my domain model, that this could be a real problem for me if I have to go through each table, column by column. Please Advise. Thanks, Albert |
|
|
Hi Albert, No unfortunately not. I can certainly appreciate this makes it fairly unworkable with a large number of tables and columns, I wish I had better news for you but unfortunately we dont detect for this condition at this time. I have made a note of this so we will certainly look at improving this as a future enhancement.
|
|
|
Jeremy, Understood. Thank you for looking into this. Albert |
|