Silverlight 4 : Update Data in DataBase - silverlight

I am looking for some Sliverlight 4 Application/ example that uses MVVM pattern to update data Back in Data-Base also.
so that I can follow that approach for Developing Silverlight Application.
any External Link will work.

Silverlight can't use Linq-To-Sql because it cannot connect directly to a database. Here is a good tutorial on getting up to speed with Silverlight and MVVM.
//EDIT -- You cannot use L2Sql directly from Silverlight. You'd have to call a WCF service to create an action on the server side that could then use Linq to Sql to read/write to/from the db.
http://msdn.microsoft.com/en-us/silverlight4trainingcourse.aspx

Related

How to use 3 tier architecture using WPF forms?

I am just starting with a new project. I have some forms which stores data and some reports. I have decided to use WPF for the purpose. I am new to WPF, so needs help. I need some sample application of WPF which stores the data in database using 3 tier architecture.
I need guidance on following points:
How to use 3 tier architecture
using WPF?
Do i need to use WCF alongwith WPF? Advantages and disadvantages??
The usual way to do something like 3-tier architecture in WPF is called Model-View-ViewModel, you should check that out.
You don't need to use WCF with WPF. I think that unless the benefits of having application tier on a different computer are significant, you should keep it on the same computer and use it as a library directly from your presentation code.
Looks like that you are talking about enterprise application architecture which contains 3 tiers (UI, BL, DB)
And WPF is a UI (frontend) technology.
So if you want to make some nice application, for UI you can choose WPF, for server communication(if you need it) use WCF services and DA layer should be at server side.
Possibly if your application is highly dependend on server, you can choose silverlight, or event ASP.NET application(there are many nice report controls).

Silverlight 4 with SQLite or alternative

I am making a Silverlight app and what I considered something straight-forward really isn't.
I am in need to create a application where a local database is stored on the web server where the Silverlight application can connect to and whenever a user goes on the application will allow sql queries to be carried out. Main use is Registration, login and event registration.
I have tried the Community SQLite: http://code.google.com/p/csharp-sqlite/
But had trouble getting it to work with Silverlight, my guess is due to poor documentation. I already have made a project containing a lot of work so I just want to implement my SQLite code into that.
Can anyone help
Thanks.
If you want your Silverlight application to have a LOCAL storage database, check out Sterling.
If you want your Silverlight application to query a centralized, server-side database, then you need to expose your database via WCF. RIA services is probably the easiest implementation.

Silverlight 4... Working with database?

I'm very new to Silverlight...
Is Silverlight development the same as ASP.NET?
I've started working on an Online University management in Silverlight 4 using Visual Studio 2010. I know that Silverlight is client-side.
Please Explain how to work with a database in a Silverlight 4 application. How do you do adding, deleting, updating (CRUD application)?
You have basically 4 options:
Use an embedded database. Some examples: Ninja database light, db4o. Most are commercial
Save your data using serialization onto the client's hard drive using IsolatedStorage: XmlSerializer is the best bet for this, and so long as you don't have too much data this is quickest method.
Use a web service reference in the Silverlight client storing no data on the client at all. All the CRUD operations are sent to the server.
Use the WebClient class to access some kind of RESTful service, getting data back in a JSON format or similar. All the CRUD operations are sent to the server this way too. As with the web services, this will be getting the data from the network each time the Silverlight app loads.

Can you use the Entity Framework directly from Silverlight?

Every example I see of data access in Silverlight seems to be using the RIA Services to get hold of the entities from the back end. Is it possible to use the Entity Framework directly from Silverlight or is that impossible and hence the need to use RIA Services instead?
It would seem that using the Entity Framework directly from Silverlight against a SQL Azure database was a much more efficient and flexible way of handling data than going via the extra layer of RIA Services. What am I missing here?
No, Silverlight has no direct database access at the moment and I don't believe it's planned. You can use RIA services or plain old ADO.NET Data Services.
You can't use Entity Framework directly in Silverlight for the simple reason that you are working on the client side at runtime.
While using EF emphasis that you have access to your database which you should don't grant to a client-side runtime.
The best solution so far is to use the RIA Services which provide an intuitive and transparent way to manipulate your data and very similar to the EF.

How to rearchitect Hibernate DAO layer of ASP.NET app to move it to Silverlight?

Last try to get an answer on this.
I have a simple ASP.NET app which uses Hibernate for data access.
GUI can call methods on Customer object like "CalculateTotalSumOfOrders()".
Lazy loading (even though it's not optimal) will work for me, and when Orders and OrderLines collections are referenced in the domain objects, they will get automatically fetched from the database.
Now let's assume I am rewriting the same very app to Silverlight because it looks better than ASP.NET.
I am NO longer able to do lazy loading or data access, because Silverlight client runs in the browser.
How can I solve this without thinking too much about what kind of service to use to get data into the Silverlight client?
Your best bet for supporting all of those platforms is to use a web service. There are many different flavors that you can choose from, .NET 2.0 Web Services (ASMX), WCF, REST, if you are using Silverlight, you may want to consider using WCF + LINQ to SQL which is demonstrated here. That combination can also be used in ASP.NET (if running on .NET 3.5) and Windows Desktop Apps (again .NET 3.5).
Also an open source project called InterLinq might be interesting to you, basically it allows you to build LINQ to SQL queries on the client side, and then transmit them through WCF to a server that executes the query and returns the result. That can be found here. I have experimented with it in the past and it works quite well.
One option that would support Silverlight and Windows clients would be the new ADO.NET Data Services in .NET 3.5 SP1. These are a set of services that expose your database schema through a WCF interface. You can then retrieve the data from Silverlight or a Windows Client using a WCF client.
As #McWafflestix has said, you won't be able to do lazy loading any more, but in my opinion that's a good thing because retrieving data is now a much more "expensive" operation.
You're trying to take a server-side app that interacts with your database and does lazy loading, and convert it into a client-side app without a lot of work? Sorry, it's just not going to work. What you need is a major rearchitecting of your application.
Sorry...
*
"That's okay because I'm quite early
there. How would you rearchitect it to
support both ASP.NET, silverlight and
windows clients with minimal
overhead?"
*
I know I am answering this question way past the expiry, anyhow here goes. I would suggest you use the MVP design pattern; this would help you build multiple "Views" to work with your Model. In order to ensure that you support Windows clients, you would have to expose your Business Layer using a services layer (read WCF).

Resources