Search code examples
visual-studio-lightswitchlightswitch-2012

Users and Employees table


I am in the process of making a database application, using LightSwitch, that tracks paperwork grouped into batches. Each of these Batches has one or more Batch_Status associated with it, and each Batch_Status has an Employee associated with it.

I want to programmatically insert a Batch_Status when a Batch is created and I want it to match up the Employee.UserName with User.Name as I want the program to work with ActiveDirectory Permissions. Any ideas?

EDIT: btw I'm using LightSwitch with VB, not C#


Solution

  • I found my own answer. I'll document it so hopefully it is useful to others. I created a query and then put this code in the Batches_Inserted Sub under the ApplicationDataService:

           Dim myQuery = currUserQuery(Application.User.Name)
            For Each e As Employee In myQuery
            Next