none
SQL Joins in Lightswitch? RRS feed

  • Question

  • Can't seem to be able to find out how to join tables and/or right custom sql queries. Where in Lightswitch do you go to accomplish this?
    Sunday, September 4, 2011 10:32 PM

All replies

  • Can't seem to be able to find out how to join tables and/or right custom sql queries. Where in Lightswitch do you go to accomplish this?


    Xzibited,

    Unfortunately, you cannot use sql queries directly in LightSwitch.  You have to use LINQ or WCF RIA services to be able to achieve the most of joining, aggregation, summing, union, etc.

    There is some minimum level of joining you can do in LightSwitch using the "Other Screen Data" item on screens to pull in related data.  You can also perform filters based on related table fields.  The other other option is to use calculated fields to pull in data from related tables, but not recommended for mass linking of related data.

    Another option is to create your database on SQL Server and then link it to your application in LightSwitch as an External database.  With this approach, you can certainly add all the various types of queries you want and then go from there.  For instance, this approach will let you import views from the sql database (i.e. the External database) and use them as tables in your LightSwicth application.  The limitation here is that, your view will most likely be READ ONLY in your LightSwitch application.  this may be fine, if for i example all your want to do is to view the output of the sql query (such as Sum, Group by, Joins, Order by, and view).

    But the short answer to your question is No, LightSwitch does not currently support SQL Queries.

    Sunday, September 4, 2011 11:19 PM
  • Thank you Cromanty! This is good information
    Monday, September 5, 2011 1:08 AM
  • umm, try to elaborate here a bit too:
    http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/6af12740-c008-4249-9f14-2f7ab791fabf

     in EF ObjectContext (inside of custom WCF RIA service) is possible to provide raw SQL and EntitySQL too


    Petr Antoš
    • Edited by petr.antos Monday, September 5, 2011 2:47 PM
    Monday, September 5, 2011 2:45 PM
  • You need to remember that the lightswitch system is a multi tia application where the different layers are seperate and not depenant on each other.

    For example you could be writing an sql query to pull data from the sql database, but you data source is actually a Sharepoint list, from the client development you do not really need to know what the backend is the engine does this for you.


    http://www.virtualrealm.com.au - XNA Game Programming News and Resources from Downunder.
    Tuesday, September 6, 2011 1:44 AM