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
|
I'm not sure if a setting on the Model is a possibility (for example, Teleriks UnderScore, Case, and Plural settings), but if it is not, would you be able to provide me with some information on where I can find the code that you use to rename the Tables and convert the case on the Tables & Columns? I really need to preserve the case of my columns and prevent the incorrect renaming of tables. i.e. EmployeeTCS gets renamed to EmployeeTc. I know they can be renamed in the designer, but this is not a suitable option for us. \I'm loading the XML from the .lsmodel and merging missing information that I need from the SQL Schema, but the renaming is throwing monkey wrenches at me. |
|
|
You can turn off case conversion by implementing an IDesignTimeNamingStrategy. There's no hook in that interface to override incorrect singularisation, but we can add one for you. I'm a bit curious as to why renaming in the designer is not a suitable option for you though? To implement IDesignTimeNamingStrategy to disable case conversion:
Using a design-time naming strategy in a model is not exposed in the UI so you need to edit the XML directly:
As I said this will not override singularisation but we can add that hook for you, but we would be interested to understand your scenario first! Thanks! |
|
|
We make a lot of changes to the database and want the model to maintain the column order defined in the database, so instead of updating the model and moving the columns around, we just delete it and regenerate it. It would be too time consuming and error prone to update the names every time we did this. Would it be possible to preserve the underscores in table names with the new hook that you proposed? Thanks for the quick response and solution! Are there any hooks that we could use to modify the .lsmodel file as it is generated? Is there a way to control the model generation (add/remove tables, execute code when a table is added, etc...) using a visual studio extension? |
|
|
Yep, I'll keep the underscore issue in mind. We don't currently have any generic hooks to modify the .lsmodel file as it is generated or updated. It's something I've thought about, but it's such a niche requirement we can't really justify it. I'd be fascinated to hear how you'd use such hooks though! If you are really determined then you might be able to interact with the model using the DSL Tools (aka Visualisation and Modeling SDK) APIs, notably Store.EventManagerDirectory -- but you would be working with undocumented ways into the .lsmodel and we would not be able to offer you any guarantees that things wouldn't break! |
|
|
We have now added a new interface (in the designer Mapping DLL) named IOverrideClrConventions. At present this has just one member, You should implement this interface on the same class as IDesignTimeNamingStrategy -- effectively you should think of it as an extension to that interface, but extending it would have been a breaking change for existing implementations. Underscores are now preserved if UseClrNamingConventions is false, so you won't need to do anything extra for that. (They were already preserved for property names, just not for entity names, so the new behaviour is actually more consistent I reckon.) These changes will be in the next nightly build, available from about 1200 GMT. Please let us know if you run into any issues or if the changes don't meet your needs. |
|
|
Is there any way to provide a relative URL to the DesignTimeAssemply? I want to keep the Strategy dll in the bin directory of the application. I would also like to be able to give the application to another developer without worrying about them having the dll in the correct place.
I would like to set the Design Time Assembly Path using "../bin/strategy.dll" |
|
|
Support for this will be in the next nightly build, available from about 1200 GMT. Paths will be tried relative to the .lsmodel file as well as the current directory. |
|
|
Wow, you are amazing! Thank you for the great support and amazing turn around time. I have never dealt with a company that had support anywhere near this calibre! |
|
|
This is still changing the Case on Foreign Key columns and renaming my Primary Key Column to Id. Is there a way to leverage the Naming Strategy to prevent these cases? I would like to keep the entity as close to, if not identical to the database conventions to prevent cofusion (for both our developers and clients). |
|
|
The identity of a LightSpeed entity is always the Id property. This is defined in the If you want a property which always reflects the Id but has a different name, you could create a wrapper property in the partial class:
However we advise against this because you can't use such wrapper properties in queries -- your application code would need to remember to query on Id rather than CustomerId which would be confusing. I'll look into the foreign key field naming, but can't promise anything. LightSpeed expects foreign key fields on the CLR side to be named XxxId where Xxx is the association name, and requires you to set Key Property Reference to override this. (Once again, columns can be named anything you like; the convention is required on the CLR side, not the database side.) So naively preserving a name like |
|
|
It appears that the Naming Strategy creates duplicate Properties for Foreign Key Columns that contain "_" in the name. These appear to store their values in different local variables, so I'm not sure what would happen when saving. If they have different values which one wins? Is there a way to prevent this? The backing fields also appear to be missing the Column Attribute that maps them back to the SQL Column with the "_".
|
|
|
This looks like you have two separate properties being considered here. I am presuming from what you have said that you only actually have one field in the database and Control_PageID would presumably be what its actually called. Does this occur when you dont use the naming strategy? If so you will want to have a look into the INamingStrategy implementation to understand why it is returning two separate properties for the one field. If it does actually occur without the naming strategy then could you be able to post the details of the table schema so we can reproduce this here and have a look into what is causing this for you. You can attach a zip file to a forum post using the "Upload a file" button below the preview area.
|
|
|
It only happens with the naming strategy and only happens to foreign key columns that have an "_" in the name. below is the naming strategy that we are using.
|
|
|
The Custom Naming Strategy is not used by Stored Procedures or the Stored Procedure "Result". This combined with the problem with the Foreign Key naming creates too much inconsistency in the resulting Model. Is there a way to get the entire Model to use the same Naming Strategy? |
|
|
Thanks for reporting these issues. I have added candidate fixes for both the underscore issue (lack of use of the UseClrNamingConventions property) for both FK's and stored procedures. This will be available in the next nightly build. Let me know if there is anything else you think is outstanding here.
|
|
|
This also resolved an issue with fields containing "_" in stored procedures returning null values. Anyone using the custom Naming Strategy should upgrade to this version. Thanks for the quick turnaround on this, I'll post if we encounter any issues, but so far this looks great! \Hands down, you have the best support out of any company I have ever dealt with. |
|