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, Our company evaluates LightSpeed (most current version - 5), we are mostly interested in using it in distributed scenario where WPF client applications connect to WCF host. Basing on the user guide and provided samples I managed to prepare working solution which uses WCF. However I encountered few problems for which I cannot find answers. I replicated my problems in very simple visual studio solution and the database which contains only two tables: “Customers “ and “Orders”; both tables have integer “ID” as primary key, table “Orders” has foreign key “CustomerID “ with ID of customer from table Customers. Let say there is a customer with ID nr 1 and name “Andrew”, for this customer I want to create new Order. For non WCF scenario I do it in following way:
Important is line:
When I assign reference to Customer then implicitly CustomerId integer value foreign key is set, this works ok - after save changes I have new order in my database. However when I want to do the same operation for WCF application:
I always get exception “Failed to commit to server”, and this is probably because in this scenario foreign key CustomerId is not being set (it has 0 value while it should have 1), however I can see in a debugger that newOrder.Customer reference is not null – it has proper values for that customer. Neverthelees CustomerID field is not set. After calling UnitOfWork.SaveChanges exception is thrown. Interestingly when I set CustomerID foreign key manually to 1 save changes commits properly. Questions:
I can send you VisualStudio2010 solution and backup of SQLServer database if it can help (should I attach it in thread or send it to you directly by an email?) . Regards. |
|
|
Can someone help me? Regards. |
|
|
re #1: This sounds like incorrect behaviour on the face of it, would you be able to send through the repro you mentioned and we can have a more detailed look into what is going on here. re #2: The message you are referring to is raised when the SaveChanges call failed (so either a ValidationException or a LightSpeedException occurred at the server). We dont surface any more specific details but this should be treated as a failure to persist due to issues at the database (e.g. FK violation or Unique violation or network failure). Based on your other comments this may occur if you have a server side validation like a unique check in which case you should do an upfront query to check for this problem before you call SaveChanges(). re #3: Server side validations such as unique checks have to be run at the server so they are ignored at the client level. In general you should validate these yourself before calling SaveChanges because as mentioned above they will be lumped in with other database level failures when reporting success/failure so you wont be able to determine specifically why it failed.
|
|