Access SQL Server database from silverlight application

Our ASP.NET website allows the user to perform many queries and displays a network diagram (such as a UML diagram) based on the result requested from the database. We are currently generating Bitmap and displaying it. But since we needed to support a feature that allows the user to show / hide certain blocks interactively, we plan to use Silverlight to render graphics. We also plan to add more interactions in the future.

I have two questions:

  • Is it possible for an ASP.NET application to send parameters to a Silverlight application.
  • The Silverlight application may have requested a SQL server database.

PS. If there are other better alternatives than Silverlight, please suggest.

+4
source share
3 answers

You must use the proper layered architecture in general and with SL; you cannot, in fact, refer to any class library that is not an SL management library.

Once you have the available DALs and your BL layers, you can set up some of the BL logic as needed using the WCF service level and use it from the SL application. See My proposed layered approach, which works with any user interface infrastructure not only with MVC and applies also if you are not actually using EF.

MVC3 and Entity Framework

+3
source
  • Yes, using query string parameters in your aspx markup, where you define your object tag.
  • No, at least not directly. You can connect the silverlight application to the WCF application, which can query your database.
+3
source

Simply put: 1 yes, 2 directly: no

Not so easy to put:

1

You can use Initparams to pass multiple (string) parameters


EDIT: If you place the following in your object code on your aspx page:

<param name="InitParams" value="keyOne=valueOne, keyTwo=valueTwo" /> 

And in your App.cs you add the following to the constructor:

 this.Startup += this.Application_Startup; 

Then in this function you can go to the init parameter dictionary.

 private void Application_Startup(object sender, StartupEventArgs e) { foreach (var data in e.InitParams) { if(data.Key.Equals("keyOne")) { //data.Value now equals valueOne } } } 

2: You can use the WCF service to communicate with the server and send and receive data (for example, database data).


EDIT:

This link explains how to host and consume the WCF service (it even explains that hosting is explained in IIS), part of the consumption works the same for WPF, Silverlight, and any other .NET program.


+2
source

Source: https://habr.com/ru/post/1380433/


All Articles