How to directly edit a record in your Microsoft Lightswitch data source?

Whenever there is a requirement to edit records by batch in my Microsoft Lightswitch project I would normally make a grid, and from the grid the records get edited.  But you can edit the records directly using the DataWorkspace object, see the code below.

Dim dw = Me.Application.CreateDataWorkspace
Dim PostedSales = (From s In dw.MyData.Sales
                   Where s.SalesNumber >= Me.SalesNumberStart  AndAlso
                         s.SalesNumber <= Me.SalesNumberEnd).Execute
For Each PostedSalesItem In PostedSales
     PostedSalesItem.Posted = "Yes"

The above code extract a set of record in the Sales table based on a series of Sales Number encoded by the user, then loop through the extracted records and update the Posted property of the table to “Yes”.

If you find this blog helpful, you can make the donation by clicking the Paypal button below.


Software developer living in the Philippines.

Posted in Lightswitch

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn


Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: