Client side Validation with RIA and EndEdit() in VM
i have come across 2 interesting situations.
1) when create new entity displayed in datagrid, mandatory fields aren't entered yet. if user clicks on save, check if there validation issues before sending unnecessary over wire.
in order achieve this, check first within cansave() method if contact.hasvalidationerrors
this true, if have valid field has gone invalid state. however how force validation check right away when entity created contact.hasvalidationerrors set right away true long mandatory fields empty?
2) other problem when field in in editmode , user clicks on save, error message have endedit() before saving.
entity 'xxx' being edited , has uncommitted changes. call beginedit must followed call endedit or canceledit before changes can submitted.
however how do within viewmodel? have no direct access view's datagrid in order call method on control? sthe best practice?
your highly appreciated,
houman
hi again,
many response first question. still investigatin ef4.1 solution, @ same time example prism documentation seems helpful.
i try ef 4.1 not support wcf ria service. thought support wcf.
i not sure understand point @ bold text. should do.
e.g.
ef generate code us.
/// <summary>
/// no metadata documentation available.
/// </summary>
[edmscalarpropertyattribute(entitykeyproperty=false, isnullable=true)]
[datamemberattribute()]
public global::system.string title
{
get
{
return _title;
}
set
{
ontitlechanging(value);
reportpropertychanging("title");
_title = structuralobject.setvalidvalue(value, true);
reportpropertychanged("title");
ontitlechanged();
}
}
private global::system.string _title;
partial void ontitlechanging(global::system.string value);
partial void ontitlechanged();
client side.
you can implement individually property ef generate @ silverlight client can see above , below.
there's partial class , partial mothod.
if need custom validate must implement inotifydataerrorinfo.
you can see prism sample how implemt interface
namespace familyevent.web
{
public partial class event : inotifydataerrorinfo
{
partial void ontitlechanged()
{
system.windows.messagebox.show("q");
}
}
}
Silverlight > WCF RIA Services with Silverlight
Comments
Post a Comment