How to establish database connectivity in Silverlight application? - silverlight

I am developing a RIA using Silverlight its completely Database Driven Application but I dont know how to establish Database connectivity?
I am using MsSQL database and C#

I found the answer to my question upto a good extent... so sharing with you all
Check this link it contains a great set of documentation on using ADO.Net data services in Silverlight.
I found one more good article so editing my answer.... but its the luck if this works for you if not then author of the article donot respond :( quite sad...
Here is the best link i found hurry!!! It solves the problem.. Lots of thanks to kencox the sample is with SQL2008 but i tried it with sql2005 and it worked so You can also try it with MySQL hope it works for you too...

Well, it depends what database you are using, if you're using mysql, you can have a look here:
http://www.mysql.com/products/connector/
And get the .NET client.

If you're making an application hosted on the Internet, you don't want the RIA directly accessing the database. Firewalls make this unfeasible, and it could expose you to dangerous attacks. Typically, you'll have a web service as an intermediary. If you really need a more direct connectivity to data, you may want to consider ADO.NET Data Services.

Related

SAP Fiori application development in angular?

we are developing an application using HTML/CSS and using the Angular framework. The problem is that we are quite a ways in to development and our client is switching to SAP, I have looked and looked and all I can find is information about SAPUI5 and Fiori. Is there a way we can still use our Angular app as a Fiori application or would we have to switch everything to SAPUI5, it sounds like a lot of work for a custom application that is practically done but I'm not an SAP expert so I was hoping someone could provide some insight around working with Fiori apps.
Thanks -
in general it is probably a good idea to choose either one of the frameworks. Changing to SAP is a bit general, i assume you do mean here SAP HANA cloud platform? If so there is no reason, why you would not be able to use angularjs to continue your application and just use the backend data services via for instance an odata service (which also should be present for a lot of other SAP applications, there is also SAP Gateway to enable this).
So all in all i think it will be possible to go ahead with angularjs, at the end also SAPUI5 is just a frontend framework.
Quick search on sdn.sap.com brings up some interesting articles that might be of help for you like the following.
http://scn.sap.com/community/developer-center/front-end/blog/2013/12/15/openui5-or-angularjs-how-about-both
In addition to what is mentioned in AirBorne04 answer, if you continue to build AngularJS application consuming oData services provided by SAP backend, you will loose all the features provided by Fiori Launchpad (which are many btw). See the link https://help.sap.com/saphelp_uiaddon10/helpdata/en/f9/51b50a07ce41deb08ced62711fe8b5/frameset.htm
Technically, this is not an issue but suppose if your customer wants to implement Fiori Launchpad then it will be an issue. So I suggest that you inform the customer about this in advance so that there are no surprises later on.

Data Access in ASP.NET MVC 3

What's the recommended way of creating a Data Access layer in real-life ASP.NET MVC applications? Is it EF? Ef Code First? NHibernate? Any other idea?
Thank you & regards
There is no recommend way.
I prefer EF Code First for doing this because
the Sourcecode is very clean and easy to read
It is easy to simple change the connectionstring and generate a new database if not already exists
easy to migrate your Database if your Model has changed (no need to recreate the Database) using EntityFramework.SqlMigrations
if your Database already exists you can use the Entity Framework Power Tools to generate the Models and Database context from your existing Database
It all depends of your need:
NHibernate is a more mature ORM with a big community
Entity Framework is now getting very well supported and you can find also great information (check Julie Lerman blog)
Both support code generation from database.
Code first: allows you to create your database schema from your domain models. This is great if you don't want to bother with database. NHibernate can do it also.
To help you decide which way to use Entity Framework
Source
There are many other great ORM:
Subsonic
Stackoverflow's ORM Dapper if performance is an important criteria there is a small benchmark on the site
If you're partial to the MSFT tooling and wanting to be "modern", then EF Code First is probably the place to start. One example worth perusing: https://github.com/NuGet/NuGetGallery .
I like to use Model First because it allows me the most freedom to design and implement in my opinion. It also makes it very easy to change the database design.
There is none, stackoverflow is full of people who have gone down the various routes, so you can get help no matter which choice you make.
Best advice, try doing a few small exploratory webs using a couple of approaches which seem to stand out.
The MVC gurus (the people who wrote MVC) at MS all seem to use Entity Framework at the moment. having said that you can use any ORM (or really any data access tech you want) as MVC doesnt actually specify anything at all about the way you access data
Try LINQ, most MVC products I see make use of LINQ.

How to query SQL Server through Silverlight web project?

I passed the hello world phase in the Silverlight world but I found out that ADO.NET is not part of the party. :_(
I'd like to know what is the easiest method to retrieve tables\rows\single value from SQL Server.
(At the moment I have a very small DB, so simplicity is more important than complicated smart solutions that can handle large amount of data.)
I what to be able to send a query like:
SELECT * FROM a JOIN b....
I found this article which I'm learning at the moment, yet I'd like to know if there are other ways to access the DB.
Thanks
Asaf
Other way is to use WCF RIA service.
You can't access a database directly from a Silverlight application.
The only way is to use some service.
Here you can learn how to do that with RIA service.
As suggested above, use WCF. This means setting up a WCF service on the webserve which does all the SQL magic. You may want to look at LINQ2SQL (obsolete) or Enterprise Framework for accessing database in this service. In Silverlight you just connect to the WCF service and it will be like magic, especially if you use LINQ.
Remember that you must access the same server your Silverlight app was downloaded from. If not there are special rules that apply.
For binding the data and interface Silverlight (and WPF) supports the MVVM model. This model really simplifies GUI implementation and makes it very easy to maintain the code.

exposing sql server data from an asp.net webapp to silverlight and win forms via linq

I have an asp.net web app which holds its data in an sql server 08 r2 db.
I have a silverlight admin interface on the same web app, and I will have a win forms app which will need to add/retrieve data from the sql db. Is there a way I can use linq in both clients?
I mean something like linq2twitter, where in the silverlight or in winforms app I can use linq to query and update the data.
Currently Im thinking of just using web services, but the data objects are complicated and they're connected to so many other data objects, it would be very convenient to work with them in linq, especially because the asp.net app itself uses a linq data context for its operations. Is there a way to expose this context over http or something?
Thanks
I think you probably want to look at WCF Data Services - which does pretty much exactly what you suggest i.e. it exposes a data context via web services (see also OData) and provides tools to consume and work with same via Linq
I tried WCF Data Services, its freaking amazing but it was a little hard to get up to speed with it, and difficult to diagnose what went wrong where, just for anyone else in my position here is what I did:
I watched this really fun scott hanselman video on OData
Landed on this msdn page after 1 hour of meandering. (Note all the snags like loading related entities, also, there is a list of unsupported linq operations on wcf ds)
Went crazy looking for some examples.
Tried my own stuff with lots of problems--> Got fiddler and then fixed all of them =)
Hope that helps!

Anyone know of a simple WPF/Silverlight data access framework?

Does anyone know of a simple WPF or Silverlight framework which enables you to e.g. define some database tables in e.g. SQL Server compact database and then the framework automatically creates the Window classes etc. which allows a user to login and edit that data?
I'm not looking for a complicated MVVM pattern example, it can be hard coded, it should just save the developer the time of creating all the CRUD code and forms and authorization necessary for users to edit the data. The developer could define 10 database tables, run the code generation, and then be pretty much 80% finished with any simple database application he wanted to make.
All of that would be generic code so I would think some framework like this would exist or someone would be working on some open source project like this already.
Does anyone know of a framework or tool like this?
It's not Silverlight, but ASP.NET Dynamic Data sounds like it would do what you're asking. It provides a web-based front end for editing database tables.
I've used it for a small project and you can literally have it up and running with CRUD functionality within an hour.
maybe you should take a look at the Sculpture project. There might be something you are looking for.
Since you cannot have direct connection to a database server with Silverlight, you should look at a .NET data access framework using the regular .NET Framework thru a Web Service.

Resources