The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: How to add Records programmatically into Entity in LightSwitch 2011
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

AliPosted Sep 2, 2013, 6:11 AM
Great thanks. How can i apply the same using a loop statement. I tried adding for each but it still only copies the selected record
majacik zajacikPosted Jan 26, 2013, 3:59 PM
can you show us how to do this in VB code please?
Donald BeatyPosted Sep 20, 2011, 4:59 PM
Thanks great article. I have master and details tables that I am importing to with code. The foreign key to the master in the details file is named and given a type of master table name by LS. It is Details_Master in the SQL server. How can I set this value programatically? I get the newly inserted value from the Master with this code: newMasterId = newMstEntity.Details.Properties("Id").Value But I get an error that the types don't match when I try to set the value of the details file. The PropertyType returned from the details entity is "LightSwitchApplication.Master". Code to add details: Dim newEntity As IEntityObject = entitySetToCreateIn.AddNew() currentProperty = newEntity.Details.Properties("Master") currentProperty.Value = newMasterId Thanks in advance for pointing out what I am missing!
Diptimaya PatraPosted Sep 6, 2011, 1:23 AM
Nice Article.