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
|
Hello - I'm running VS2013 Pro and Lightspeed 5, nightly build from June 4. I am using LIghtspeed in a WCF service where the client references the Lightspeed DLLs and Model DLL from the service, copied to a separate directory. I am not using DTOs. I have a computed column I want to load from a database entity (FullName = FirstName + ' ' + LastName) and forward on to the client. I searched the archives and found several references to computed columns so I made sure to set the field to Load Only = true. However, when I try to forward this entity to the client I get a System.Runtime.Serialization.InvalidDataContractException saying there is no set property for that field. Digging around in a couple other places (StackOverflow), I learned you need to have a private or protected set property in order for the deserializer to work properly. Lightspeed does not generate this by default. I tried setting the Private Setter option on the column in the designer, but that didn't do anything. When I re-read the comment for the property I can see why, but it was worth a shot. From what I can tell, the only way to accomplish what I need to do is to set the Generation property to FieldOnly and write custom getter and setter code for the partial class. Really? I would have thought that as slick as this product is you guys would have built in support for this scenario. Is there a better way or is this really how it has to be done? Thanks for the great product and fantastic support! Dave Newman |
|
|
Hi Dave, Yes the approach here is to implement your own property by using the FieldOnly generation option.
|
|
|
Thanks for the confirmation. Any chance this could be a design-level option at some point? I haven't used computed columns prior to this so haven't had the need for it, but it seems this is a common enough usage pattern it might be worth your time and effort to implement designer support for it. Just sayin' :) Dave |
|
|
OK so I got most of this working, but Lightspeed seems to still be trying to save the computed column to the database. Here's what I have done so far: Set Generation to FieldOnly and Load Only to True in the designer. Here's the code from the model.cs file:
And here's my custom property:
What am I missing? I'm thinking there should be something in the code, generated or custom, that tells Lightspeed not to persist the field, but I don't see it, and the error I get when trying to save the Employee record tells me it's probably not there:
Thanks, Dave |
|
|
Hello? I really need an answer to this and I can't seem to find what I need to do to keep Lightspeed from trying to save the computed column back to the database. Help! Dave |
|
|
Hi Dave, Is the field being generated as readonly? If not does adding the readonly specifier resolve the issue?
|
|