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
|
Hi Guys, I have been struggling with this little gem for a last day and a half and I finally cracked it. I have a 2 models, that has all of my database properties which works fine, I then have a partial class to each entity which implements special logic. This all works great however when a add a property to the partial class (not the model one) then model can save data to the database. Not only does it break the model that the property is part of but it beaks both my models. Does anyone have any ideas on why this is happening and how I can have properties on a partial class linked to a model that are not for the DB? Thanks Again, Josh |
|
|
This is probably because LightSpeed tries to load and save all your fields, including those defined in the partial class, to the database. (At runtime, the generated and partial classes have long since been merged, so LightSpeed doesn't know whether a property was defined in the model or the partial class.) If there's no corresponding column, this will fail. The fix is to mark any fields that you don't want saved with the TransientAttribute: [Transient] Note this must be applied to the FIELD, not the property. (And since C# 3 automatic properties generate an inaccessible backing field, this means you can't use auto properties in a LightSpeed partial class.) I'm not sure why this would "break" both models: it shouldn't actually matter unless you try to load or save an entity of the troublesome type. If the [Transient] fix doesn't solve the problem, post us a repro and we'll investigate! |
|