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
|
Determines how LightSpeed generates times for automatic timestamps such as CreatedOn (track create time), UpdatedOn (track update time) and DeletedOn (soft delete).
I have a lot of legacy tables that have fields like CreatedDate, ModifiedDate and so on. I would like to be able to set the column names for Created, Updated, Deleted and any other field that LS can control. Thanks. Joe Feser |
|
|
You can already do this for the runtime using the LightSpeedContext.NamingStrategy. Just create and hook up an INamingStrategy implementation that returns the appropriate names for the special columns -- e.g. the GetCreatedOnColumnName method might look like this: public string GetCreatedOnColumnName(string defaultTableName, string className, string defaultName) { (You can just return defaultName from anything you don't want to customise.) This isn't currently supported in the designer -- let us know if that's what you're after. |
|
|
Does this mean I should return null if I do not support that special column. This is what I am looking for. I did not know it was not in the designer support. Thanks. Joe Feser |
|
|
It doesn't matter too much what you return for special columns you don't use, because LightSpeed won't call your method if it never encounters that kind of column. However, I'd recommend returning defaultName rather than null, so that if you subsequently add a new table that does use that kind of column, it will just work, rather than giving you mysterious "no such column ''" errors. |
|
|
Are you saying this is global and not per table? Don't ask why but there were a few spelling mishaps over teh decade+ that some of this was written and I need to to be per table. If not, I will just create a partial class and manually mange those fields. It is just nice now I don't have to mess with the timestamp fields with LS. Joe Feser |
|
|
The naming strategy object is global (well, context level). However, note that in the methods you implement, you do get given the entity type name and the table name. So you can handle your, er, unconventional names here: public string GetCreatedOnColumnName(string defaultTableName, string className, string defaultName) { Then in your app.config / appSettings section: <add key="SomeAncientTable.createdOnName" value="CraetoinDeat" /> (Obviously if there are a significant number of these things then you'll probably want something more structured than a bunch of keys in appSettings -- but you get the idea I'm sure!) |
|