Linked entites

2 posts, 0 answers
  1. Maxim
    Maxim avatar
    2 posts
    Member since:
    Apr 2011

    Posted 04 Aug 2014 Link to this post

    I have two entities
    RealEstate and Hierarchy. They are linked many to one (RealEstate 1 <-->
    * Hierarchy).

    RealEstate has navigation property "Hierarchies".

    Hierarchy has navigation property "RealEstate".

    As soon as my tables contain more than 1 million rows there is no possible to
    set managed link.

    Scenario 1: Add entities natively.

    CoreModel context = new CoreModel();

    var realEstate = new RealEstate { Title = "", RecordStatus =
    RecordStatus.Active, Version = 1, RegistrationDate = DateTime.Now };

    var hierarchy = new Hierarchy { HierarchyTypeId = 12 };

    hierarchy.RealEstate = realEstate;



    OK. No errors.

    Scenario 2. Add entities through WCF (5.6.1)

    var realEstate = new RealEstate { Title = "", RecordStatus =
    RecordStatus.Active, Version = 1, RegistrationDate = DateTime.Now };


    var hierarchy = new Hierarchy { ParentRealEstateId = null, HierarchyTypeId =
    12, UniqueId = Guid.NewGuid(), CharacteristicTypeId = 21 };


    context.SetLink(hierarchy, "RealEstate", realEstate);



    <?xml version="1.0" encoding="utf-8"?><m:error
    /><m:message xml:lang="ru-RU">При обработке этого запроса
    возникла ошибка.</m:message><m:innererror><m:message>No row
    for FondRGS.RZU.Core.RealEstate ('entity_RealEstate') GenericOID@3d330985

    With help of Fiddler, I see than passed entity has navigation property with new
    generated realEstateId.

    <link rel=""
    type="application/atom+xml;type=entry" title="RealEstate"
    xmlns="" />

    But ORM tries to use RealEstateId values instead of RealEstate (property). The
    same works like a charm in EF 5.

  2. Viktor Zhivkov
    Viktor Zhivkov avatar
    290 posts

    Posted 06 Aug 2014 Link to this post

    Hi Maxim,

    I am afraid that this is a limitation of our implementation of Data Services.
    My suggestion will be to separate the procedure in Scenario 2 into 3 actions:
    1. Save the new RealEstate instance
    2. Save the new Hierarchy instance
    3. Link both object by updating the Hierarchy instance foreign key.
    While this approach will work you should consider the fact that there will be 3 distinct transactions rather than single one as you intended.

    Viktor Zhivkov
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
  3. DevCraft banner
Back to Top