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.
Related
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
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.
I am thinking about porting my alpha WPF MVVM application to silverlight.
I do not use 3D its a LOB ;-)
What I promise myself from the conversion is to get more customers in the end (Mac/nix user do not pay well ;P).
1.) At the moment I am using sqlite as database. Is it possible, that I can access the sqlite file on the harddisk of my user to read/save data? (on User dir its possible but access an USB stick ?)
2.) Is there anything concerning MVVM silverlight can not handle?
3.) Does SEO work well with Silverlight 4?
1.) At the moment I am using sqlite as database. Is it possible, that I can access the sqlite file on the harddisk of my user to read/save data? (on User dir its possible but access an USB stick ?)
If you want to use a local database then you'll either need to install your Silverlight application on the local machine as a full trust application or use a database that installs into Isolated Storage like SiaqoDb (as suggested by #Shawn Mclean). You won't be able to access a USB stick.
When run in a browser across the net it has limited access to the local hard drive for security reasons. If you're doing this you might as well stick with WPF.
2.) Is there anything concerning MVVM silverlight can not handle?
You can use Prism to develop MVVM applications for Silverlight as well as WPF.
3.) Does SEO work well with Silverlight 4?
I don't know a great deal about this, but Silverlight can be viewed as Microsoft's version of Flash so it will probably have the same SEO issues as Flash. The code is compiled and delivered to the client in binary form, so unless you split your application across multiple HTML/ASP.NET pages there won't be anything for Google to index. Apparently Flash does support SEO, but I haven't looked into SEO and Silverlight.
1.) At the moment I am using sqlite as database. Is it possible, that I can access the sqlite file on the harddisk of my user to read/save data? (on User dir its possible but access an USB stick ?)
The basic principal of Silverlight is centralised data over services. You can have local data, but that is not as useful generally compared to a central storage. You then have no worries about full trust as it will run in any Silverlight browser.
You can use SQLLite on your server, however the best free database option we have found is SQL Service Express 2008 R2.
You can access USB, but it requires both OOB, Full Trust and a custom COM automation object installed on the client (so Windows only). Basically forget local USB storage and support downloads instead, if local copies are needed.
2.) Is there anything concerning MVVM silverlight can not handle?
Bindings in Silverlight 4 are now very similar to those in WFP. Accessing parent elements from templates is a little more difficult, but most simple bindings are the same.
3.) Does SEO work well with Silverlight 4?
First ensure that you provide a sitemap for the searchengines. That should map to all content pages.
Provide a parallel ASP.Net website to publish your content for the search engines to read. This is now quite easy with RIA services as an ASP.Net website can consume a RIA service just like any other WCF service.
Make good use of headers, meta tags, titles, human-readable urls to include relevant keywords.
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).
I am writing an applicaton that will be a standalone WPF application and also a cut down version that will work as Silverlight and so be hosted in browsers. I want the Silverlight application to access data from the cloud. The WPF application needs to work against a local database but then be able to sync with the same cloud storage.
So I need the following scenarios to work. Silverlight works directly against the data stored in the cloud. The WPF app works against a local database. But the WPF app has the ability when it starts up to go to the cloud and get the latest version in case of changes being made online since the last time the WPF app was run. When the user finishes on the WPF app it can then sync up the changes made to the cloud again. This allows better performance during WPF being run and also allows you to run it offline and sync up later when you have a connection.
What is the best technology available to do this? I know there is a Sync Framework, SQL Server Data Service, ADO.NET Entity Framework and SQL Server Compact Edition that help with data access but I am not sure if they can be made to work together to do the presented scenario.
Do I implement all this myself? Does most of it come for free and I only need to handle the syncing? If you have deep knowledge of the Microsoft data access technologies then I would appreciate your input on the design.
Your scenario would be easy with a standard SQL server backend. :)
However, I think what you're proposing is doable for the most part. For the WPF app and syncing to the cloud with SSDS you could use Project Huron (which has downloads coming "soon"). That would keep your SSDS data in sync with the WPF client apps.
For the silverlight side you could use the REST api of SSDS (or a helper library like SSDS Rest).
So you won't need to implement most of it yourself, but whenever you head down a road like this one there are always lots of little roadblocks to run into along the way. Have fun!