This is a migrated thread and some comments may be shown as answers.

Linked entites

1 Answer 86 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Maxim
Top achievements
Rank 1
Maxim asked on 04 Aug 2014, 05:28 AM
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;

context.Add(realEstate);

context.SaveChanges();



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 };

context.AddToRealEstates(realEstate);



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

context.AddToHierarchies(hierarchy);

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

context.SaveChanges();



Error:

<?xml version="1.0" encoding="utf-8"?><m:error
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code
/><m:message xml:lang="ru-RU">При обработке этого запроса
возникла ошибка.</m:message><m:innererror><m:message>No row
for FondRGS.RZU.Core.RealEstate ('entity_RealEstate') GenericOID@3d330985
RealEstate
Id=0</m:message><m:type>Telerik.OpenAccess.OpenAccessException</m:type>



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

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RealEstate"
type="application/atom+xml;type=entry" title="RealEstate"
href="http://test/CoreService.svc/RealEstates(1545560L)"
xmlns="http://www.w3.org/2005/Atom" />



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



1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 06 Aug 2014, 03:23 PM
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.

Regards,
Viktor Zhivkov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Data Access Free Edition
Asked by
Maxim
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or