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 use designer for generating UnitOfWork and entity classes. When I drag table from server explorer, designer renames field names. For example if database column name is “Prefix_FieldName_Postfix”, entity property name will be “PrefixFieldnamePostfix”. If i leave “PrefixFieldnamePostfix” entity name unchanged all works fine. But if i change entity name to “Prefix_FieldName_Postfix”, following code (see attachment) throws exption: var throwsException = (from lightSpeedTests in unitOfWork.LightSpeedTests where lightSpeedTests.Prefix_FieldName_Postfix == "1" select lightSpeedTests).ToList(); {"Query Error: Could not find field [Prefix_FieldName_Postfix] on model [LightSpeedTest]"} Can i suppress changing of database names in designer or safely rename entity property name?
|
|
|
I think this is a bug with our handling of property names that do not conform to .NET naming conventions. The property uses the unconventional name but the designer gives the backing field a conventional name (with the underscores taken out), which prevents LightSpeed from locating that backing field when it comes to build the query. I will investigate further and try to provide you with a fix. However, we would generally encourage you to use CLR conventional names for properties, i.e. PascalCasedWithWordsRunTogether rather than Words_Separated_With_Underscores, because the object model consists of .NET objects and should be consistent with .NET conventions. In particular, depending on what the Prefix and Postfix are in your real scenario, you might be able to get rid of them altogether -- e.g. if these are Hungarian-style things like a col_ Prefix then we would suggest you probably don't want them in your public property names anyway -- and then FieldName, which conforms to the .NET naming conventions, would avoid the bug. But I will look into getting you a fix anyway -- thanks for letting us know about this. |
|
|
I've committed a fix for this and it will be in the 16 June nightly build, available from about 1430 GMT. Please let us know if you still see the problem. |
|
|
Using of underscores (_) is usefull in naming of relation tables in database. For example if you have two tables: Employee and Phone, relation table name will be Employee_Phone. When i see such name, i know that i can find Employee and Phone tables. In this naming convention name EmployeePhone would has some another meaning.
|
|
|
http://www.mindscape.co.nz/forums/Post.aspx?ThreadID=2102&PostID=5646
|
|
|
I have recrudescence of this issue.
Way of reproducing: 1) Mapped entity property with underscore symbol in name (i. e. prefix_fieldname) 2)Folowing code throws exception : var list = unitOfWork.SomeEntities.Where(someEntity => someEntity.prefix_fieldname == 1).ToList(); {"Query Error: Could not find field [prefix_fieldname] on model [SomeEntity]"}
Unfortunatly i cannot reproduce the issue on test solution and i cannot figure out conditions this issue depends on.
|
|
|
nightly build 20090802 |
|
|
Can you post the source code for the SomeEntity class? It sounds like the backing field name may be incorrect but we would need to see the code to know if this is correct and to diagnose the cause. |
|
|
Indeed, one of my co-workers used old version of lightspeed disigner (runtime libraries were ok). It would be useful to display warning if version of current designer is uncompatible with version of designer had generated the editing model cs file. It is possible by using
[ System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]attribute. Now version is always 1.0.0.0 |
|
|
Thanks for the suggestion -- I've logged a feature request for this but it's not likely to happen in the short term I'm afraid. |
|