Silverlight 4 OOB with local data options

2020-07-22 09:36发布

Right now I have a Winform app with a SQL Server back end. The DAL is comprised of Linq to SQL. One of the complexities of this app is it's need to function offline.

I have accomplished this by using Merge Replication to keep there local SQL Express instances in sync with a central SQL Server. I have some logic that detects there connection state and switches the contexts connection string appropriately.

My question is thus, will this also work with Silverlight 4? In theory, I would detect when they are offline and switch the connection appropriately. Thoughts?


EDIT

It seems this is, in fact, possible. See HERE.

What I NOW would like to understand is if I could make EF or L2S work with this instead of RecordSets like it shows.

2条回答
成全新的幸福
2楼-- · 2020-07-22 09:50

With Silverlight (any version) the problem isn't so much connectivity to the database. In Silverlight, you don't have it. The only thing you can do is make a call back to the server that the request originated from.

Because of this, you would have to have some sort of local IIS instance running and connect to that, which would then in turn connect to the local SQL instance.

The thing is, if your SL application was loaded from your site, and then connectivity was lost, your app couldn't detect it. You would have to go to a new link to the server on the local machine and then have them switch back when they have connectivity again.

For something like this, it's probably best that you stick with the Winforms app and determine whether or not you have connectivity there. That way, you can switch which database you hit when you don't have connectivity.

查看更多
Fickle 薄情
3楼-- · 2020-07-22 10:01

What casperOne is saying is that out of browser Silverlight does not have access to a full fledged database on the client. The best that can be done is to use some sort of compact database either in the isolated storage or within one of the few accessible folders with Silverlight 4. I have personally used siaqodb.com , but you will have to keep the data synchronized manually (which can be a nightmare).

More recently I have seen someone get access to a SQL compact database. However, there could be more ways of accessing data now. It has been some time since I've looked for a client side database for Silverlight.

查看更多
登录 后发表回答