Tek Freak
jake of all trades

Problem : LS allows a master record to be deleted (in screen) even though the entity has few children exist with “Restricted” relationship between them.  But it generates the validation error when we try to save the entity and there is no way to get rid of them (by design).

Summery : In LS “Beta2″ days, I posted a bug and acknowledged by LS Team. Now I created a project to see if this bug was cleared. It actually did (now LS assigns “1″ as a starting number of ID entities), but found another issue with it.  And I’m not sure, whether this one was pre-exist in Beta2 or not.

On Screen Level, even if my entities’ relationship has ‘Restricted’ deletion, LS actually allows to delete the Master record when there are child records exist and it catch this when the records are trying to post back to DB with SAVE method.

If we try to delete an “existing Master record”, at least now we have a choice to go back and delete the child records one-by-one on the screen, as LS put a “X” icon next to the master record, but at least it still exist in the screen.

But if we delete a newly added master record with children (that are not exist in DB), now LS clears the master/child records from the SCREEN and there is no way to get rid of its validation errors, when we try to SAVE the screen.

You can see these series of screen shot of what I mean.

This slideshow requires JavaScript.

Workaround : Right now, all what I did was restrict Master’s deletion method by overriding its code with below.  What I expect from LS is that, it should capture this ‘Restricted’ association on the screen and should prevent deletion.

[sourcecode language="csharp"]
partial void TempProductListDeleteSelected_CanExecute(ref bool result)
{
if (TempProducts.SelectedItem == null)
return;
if (TempProducts.SelectedItem.TempOrderDetails.Count() > 0)
result = false;
else
result = true;
}
[/sourcecode]

Discussion Threads

https://connect.microsoft.com/VisualStudio/feedback/details/686639/bug-in-master-detail-deletion#details

http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/e65b634e-c1f2-471e-9a8c-33507cd59020

http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/081099b2-4365-4a30-8914-68a6566e7600

 

 


Eine Antwort

Post Comment

Please notice: Comments are moderated by an Admin.


Powered by Wordpress
Theme © 2005 - 2009 FrederikM.de
BlueMod is a modification of the blueblog_DE Theme by Oliver Wunder