Wednesday, December 22, 2010

Stored Procedures in LightSwitch

I do understand that Visual Studio 2010 LightSwitch should be a simple tool for building simple applications, but I would like it to be able to run stored procedures as well.
If you agree with me, please vote for this proposal on Microsoft Connect: https://connect.microsoft.com/VisualStudio/feedback/details/632862/run-stored-procedures-from-lightswitch

As always there is a complicated way to run stored procedures in code.
You could to define a custom WCF RIA Service that exposes your database stored procedures. Then add the RIA Service as a data source.

It is also described in this article:
http://tejana.wordpress.com/2010/12/09/microsoft-lightswitch-and-stored-procedures-using-wcf-ria-services/

However, why should thousands and thousands of developers write something that is relatively complicated and clearly infrastructure work? The deal between business developers and MS developers is that MS provides infrastructure and we do business functionality.

Isn't it better for MS to include this in LightSwich so that developers does not have to write this again and again and again? (Maybe Microsoft should find motivation to do this in how much will they save on support if they do not have to explain and debug this to thousands of people.)

1 comment:

  1. Here's a slightly better option:

    Create a Web API controller class
    Within that, create a ServerApplicationContext
    Within that, use some good old fashioned ADO.NET, SqlCommand, SqlDataReader etc.

    Details here:
    http://blogs.msdn.com/b/lightswitch/archive/2013/04/25/create-dashboard-reports-with-lightswitch-and-webapi-part-deux.aspx

    ReplyDelete