none
Linq-to-sql Changed event of object not available RRS feed

  • Question

  • I want to be able to capture the OnChanged event of a Foreign key object, but that doesnt't seem to be possible by default.

    Example:
      
    ObjectA a = new ObjectA();
    a.ObjectBID = someID;

    This triggers the "ObjectBIDChanged" event which Linq-to-sql by default offers.
      
    ObjectB = myDatacontext.ObjectBs.GetItemByID(someID);
    ObjectA a = new ObjectA();
    a.ObjectB = objectB;

    This doesn't trigger an "ObjectBChanged" event. It isn't available. Why is this and better yet, how can I achieve this without altering the dbml-designer-file?

    • Edited by steeffie Thursday, December 1, 2011 10:45 AM
    Thursday, December 1, 2011 10:34 AM

All replies

  • Hi steeffie,

    Based on the code above, the ObjectB seems like a class, not an instance. Could you please explain more clearly about your scenario, this is so I can help you more effectively.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Sunday, December 4, 2011 2:06 PM
    Moderator
  • Hi steeffie,

    Have you fixed your issue? I look forward to hearing from you. If you have any problems, please feel free to let me know.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, December 7, 2011 2:01 AM
    Moderator
  • No I haven't fixed it. Though i have a workaround for it, but it's not a very clean solution. I added an extra property which just gets and sets (Foreign key)-member ObjectB and in the setter I make a call to ObjectBChanged. This is far form optimal, but haven't a better solution yet.

    Wednesday, February 22, 2012 10:30 AM