Search code examples
c#linqvisual-studio-lightswitchlightswitch-2013

How to "extend" query in Lightswitch?


I need to present data from two tables in the same view. When I use a calculated property I get a performance penalty that is currently not acceptable.

If I would have done it using only SQL it would be possible using a JOIN. I also know how to do it using linq and entity framework.

The problem is that Lightswitch only lets me execute queries that results in a list of existing entities.

I'm creating a Desktop Client.


Solution

  • If the correct relationships have been set up, it is possible for data items from multiple entities to be displayed concurrently solely using built in queries. Your question doesn't really have enough detail to know whether that would work here, but it's always the best way to go if you can so that you keep the benefit of all the other automagical Lightswitch features.

    If it's not possible using built in queries or I really do want to change the shape of the data and not just return Lightswitch entities, I usually use a WCF-RIA service. This sounds like a good approach here as it would leverage you LINQ knowledge too.

    http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/2226/Creating-a-WCF-RIA-Service-for-Visual-Studio-2013.aspx covers how to do this in VS2013. It's one of those things that sounds complicated at first but is actually OK if you follow carefully.