开发者

Silverlight 4 calls SQL server query command

My Silverlight 4 application has a DataGrid control which needs to displa开发者_StackOverflow中文版y data rows from SQL server query command (e.g. SELECT * FROM TABLE...). Is there any solution? Do I need use WCF or ADO?

Thanks a lot for any help.


Based on your description of "DataGrid control which needs to display data rows from SQL server query command" you want to use RIA services.

  • Create a RIA services Silverlight project (or enable RIA services on your existing project)
  • Create an Entity Framework model referencing your SQL server table
  • Create a Domain service that uses your EF model
  • After building the project you will then be able to see your tables in the Data Sources window
  • From the Data Sources window you can directly drag a grid, representing that table, onto a page. This will create a DomainDataSource as well as the DataGrid and wire it all up for you.
  • The only bit you will need to add is paging.

Here is some more information about this process: http://msdn.microsoft.com/en-us/library/ee707376(v=vs.91).aspx

I know it sounds like a lot or work, but once you get used to the steps it is all pretty simple (and makes the draggy-droppy stuff work really well).


Silverlight cannot, at the moment, access databases like Sql Server or Oracle directly.

To access data you have to use some form of service as a gateway to your data.

Pure WCF is an option.

You should also take a look at WCF RIA Services.

This a good link to see what else is available. http://wildermuth.com/2010/07/08/State_of_Data_Access_in_Silverlight_4

You can also take a look on project Agatha-rrsl. http://code.google.com/p/agatha-rrsl/

The above are all free.

There are non free alternatives too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜