Where to put C# code to handle Entity Changed Event RRS feed

  • Question

  • Hello,

    I am attempting to copy data from the selected row to the new row.   To accomplish this I am using the Entity Changed Event.   It works but every other time I rebuild the app, my code is replaced by the default Entity Changed Event procedure which is pretty much emtpy.  Since my code is now gone the copy row functionality  is gone.

    Where should I put the code to make it so it does not get overwritten?

    Should I be using a "Private void" ?  or do I need "Public Void" or "Partial Void" ?? 

    Any pointers would be greatly appreciated.

    Below is the code in case that helps: 



    if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)



    if(this.QC3rdPartyTestings.Count > 1 & e.NewItems.Count == 1)





    QC3rdPartyTestingNewDetail = (QC3rdPartyTesting)e.NewItems[0];


    QC3rdPartyTestingCurrentDetail = this.QC3rdPartyTestings.SelectedItem;

                            NewDetail.InternalSampleNumber = CurrentDetail.InternalSampleNumber;

                            NewDetail.QCVendor = CurrentDetail.QCVendor;






    Trace.TraceInformation("Error."+ ex.ToString());









    Kameron Voller

    Thursday, February 28, 2013 8:37 PM


  • They are 'partial void'. If you add the event stubs using the LightSwitch menus you cannot go wrong: write code, view code, etc...

    If you try doing it manually typing 'partial ' will invoke intellisense to list the events available (C#) once you type the space.

    Dave Baker | Xpert360 blog | twitter : @xpert360 Opinions are my own. Please mark as answer if this helps solve your problem.

    • Marked as answer by Kameron_V Thursday, February 28, 2013 9:22 PM
    Thursday, February 28, 2013 9:15 PM