Saving Data in a SilverLight Webpage
im trying to perform a simple database insert from a submission on a SilverLig开发者_运维技巧ht Webpage. Normally i would either use ADO or LINQ to SQL to perform this. You can not do this within a SilverLight Project, nor can you reference a project that can (a non SilverLight project). What would be the best way of doing this?
Thanks.
For the most part, Silverlight apps are designed to talk to web-based data services or databases via RIA services.
There are a a few approaches to your problem:
- Reference a web service, like an .asmx or any REST servie
- Use WCF to communicate to the backend
- Use Silverlight RIA Services to talk to the database (it was designed to solve your problem)
Your best bet is to use the .NET RIA Services which will allow you to define server-side domain classes and due to the RIA Services link, will generate client side code in your silverlight project.
Another alternative if you don't want to use web services, is to Xml Serialization and Isolated Storage to store the files. You'd simply load the database into memory on startup, and then persist to the file when the apps closes, or periodically.
精彩评论