user1799596
user1799596

Reputation: 117

Display Distinct values in LightSwitch browse screen

i have one browse screen which is fetching value from one entity(Attached to SQL datasource), the entity will look like the below snapshot. enter image description here

So in the browse screen its coming with all row values (1,2,3 and 4) even though i removed the Role field from the screen. I want to display the distinct Emp ID, Name, Age. Please give me some suggestion.

Upvotes: 0

Views: 286

Answers (2)

Phil
Phil

Reputation: 271

The question tags Lightswitch 2013 and 2012 so it's not clear what the OP is using. Views handling in Lightswitch before VS2013 Update 2 can be a little more challenging (particularly around the definition of key fields) so the other possibility is to use a WCF-RIA service to reshape the data. Having a WCF-RIA service ready to go always comes in handy eventually, even if there are annoying limitations and quirks there as well.

The exact steps depend slightly on what version of VS you are using:

The canonical article by Eric Erhardt - http://blogs.msdn.com/b/lightswitch/archive/2011/04/08/how-do-i-display-a-chart-built-on-aggregated-data-eric-erhardt.aspx

An up to date version for VS2013 - http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/2226/Creating-a-WCF-RIA-Service-for-Visual-Studio-2013.aspx

Happy to help further with specific queries if you decide to go down the WCF-RIA route.

Phil

Upvotes: 2

Chris Cook
Chris Cook

Reputation: 2841

If you don't have the option of driving your Browse screen from your employee table I'd suggest creating a SQL view similar to the following: -

CREATE VIEW [dbo].[EmployeeView]
    AS
SELECT DISTINCT 
    EmpId, 
    Name, 
    Age, 
    Role
FROM
    dbo.YourTable

You can then attach to the view in LightSwitch and base the Browse screen on the attached view.

However, please bear in mind that you will only be able to view and not update the information as this type of view uses the DISTINCT clause.

The following blog post provides some basic details of using views in LightSwitch: -

Attaching to SQL Views

Upvotes: 1

Related Questions