How do I submit a Linq data class through WCF and bind the input control to this class property?
For a strongly typed and safe solution, I have to take the next step.
- Create a Silverlight application.
- Controlling input binding to the Linq data class.
- Validate data using a rule from a data class attribute.
- Sending data to the server via WCF.
But I have a question.
- How to bind input control to property of linq data class?
- How to do this with minimum levels (s) and minimum required dll (for Silverlight project)?
PS. .Net RIA Service - May preview is not my definitive answer. Because the size of all the required DLL and some generated code.
thanks
a source to share
Ok, I'm glad you know that .NET RIA Services will provide all of these things, but I understand that size is a consideration. Keep in mind that since it looks like you are looking at Silverlight 3, you can use the assembly caching option to significantly reduce the Xap size:
I'm not sure if caching applies to RIA Services assemblies, but if so, they will only be loaded once.
Assuming not what you want, there are two more options for getting data from Linq classes (assuming you mean Entity Framework classes) for the client. The easiest way is to create your own WCF service as you mentioned. So you write data classes on the server and proxy classes are automatically generated on the client that mimic the server classes. The downside here is that business rules will not be shared between them. Thus, your data validation attributes should be recorded and used on the client and server separately.
The next option is to use ADO.NET Data Services to transfer data from server to client. This is a step above the previous option because you don't need to write the WCF service yourself to host the data; it is made for you. Of course Xap requires an additional Dll.
To answer some of your questions directly:
- You can never bind input control directly to the Linq data class. You can only bind controls to client side proxy classes that are generated by referencing a WCF service (either you wrote yourself or provided ADO.NET data services).
- If you are not using .NET RIA Services, you need to create a custom attribute to reference your business rules and then manually handle events in the data bindings to read the attribute and apply your rules.
- Use any of the above options to send data to the server — either your own WCF service or ADO.NET Data Services.
Your last question about binding an input control to a property looks like this:
MyControl.xaml.cs:
public MyControl() {
this.DataContext = new LinqDataClass();
}
MyControl.xaml:
<TextBlock Text={Binding PropertyOnLinqDataClass}/>
Here LinqDataClass is the client side view of the server side Linq data class and has a PropertyOnLinqDataClass property. You will need to implement the INotifyPropertyChanged interface on the client side to properly support 2-way data binding.
a source to share