You must Sign In to post a response.
  • Category: LINQ

    Get Foreign key relationship dynamically

    Hello
    I want to know is there any method in "Linq/ Entity framework" to identify the relationship exists between two entities. For Example:
    I have a string which contains DB entities separated with comma as shown ("Employee,Department"). I want to compare the Employee and Department to know is there any relationship exists.
  • #752604
    Hi,
    Why can't you use LINQ to SQL in this case? If you are new to this please go through the MSDN tutorials: msdn.microsoft.com/en-in/library/bb425822.aspx


    Regards,
    Asheej T K

  • #753319
    In order to get relationships of a particular object , you need to get the RelationShipManager reference in code using following syntax and then check the HasRelationships property to know if the relationship exists.

    objectcontext.GetRelationshipManager(object)

    Relationship manager identifies the relationship between different entities.

    Miss. Jain
    Microsoft Certified Technology Specialist in .Net


  • Sign In to post your comments