BarCodeId FK を ContactDocument で null を許可するように変更した場合。その後、ContactDocument のいずれかのエンティティに null の BarCodeId がある場合、クライアントでエラーが発生し始めます。最後の 3 つの展開を削除すると、すべて機能しますが、BarCode オブジェクトに関連するエンティティは取得されません。ヘルプはありますか?
IQueryable<ScanDocument> result = Context.CreateQuery<ScanDocument>("DocumnetsWithNotRemovedContacts")
.Expand(ScanDocument.ScanDocumentDetailsPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ScanDocumentPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.BarCodePropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.ContactDocumentsPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ScanDocumentDetailPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.ContactSourcePropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.ElectionDistrictPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.ContactTypePropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.ContactSalutationPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.ContactGroupsPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.ContactPropertyName + "/" + Contact.CategoryInterestsPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.BarCodePropertyName + "/" + BarCode.ContactDocumentsPropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.BarCodePropertyName + "/" + BarCode.BarCodeActionTypePropertyName)
.Expand(ScanDocument.ScanDocumentDetailsPropertyName + "/" + ScanDocumentDetail.ContactDocumentsPropertyName + "/" + ContactDocument.BarCodePropertyName + "/" + BarCode.ScanDataTypePropertyName)
.OrderByDescending(document => document.ID);
サーバー側では、ネストされたプロパティを取得するためにこのようなものを使い始めました。
CurrentDataSource.ScanDocumentDetails
.Include(ScanDocumentDetail.ScanDocumentPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.BarCodePropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.ContactDocumentsPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ScanDocumentDetailPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.ContactSourcePropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.ElectionDistrictPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.ContactTypePropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.ContactSalutationPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.ContactGroupsPropertyName)
.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.ContactPropertyName + "." + Contact.CategoryInterestsPropertyName)
//.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.BarCodePropertyName + "." + BarCode.ContactDocumentsPropertyName)
//.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.BarCodePropertyName + "." + BarCode.BarCodeActionTypePropertyName)
//.Include(ScanDocumentDetail.ContactDocumentsPropertyName + "." + ContactDocument.BarCodePropertyName + "." + BarCode.ScanDataTypePropertyName)
.Where(c => ids.Contains(c.ScanDocumentID ?? 0)).ToList();
foreach (var scanDocumentDetail in y)
{
foreach (var contactdocuments in scanDocumentDetail.ContactDocuments)
{
if (contactdocuments.BarCode != null)
{
int barCodeActionTypeId = contactdocuments.BarCode.BarCodeActionTypeId;
contactdocuments.BarCode.BarCodeActionType =
CurrentDataSource.BarCodeActionTypes.FirstOrDefault(p => p.ID == barCodeActionTypeId);
if (contactdocuments.BarCode.ScanDataTypeID.HasValue)
{
int scanDataTypeId = contactdocuments.BarCode.ScanDataTypeID.Value;
contactdocuments.BarCode.ScanDataType =
CurrentDataSource.ScanDataTypes.FirstOrDefault(p => p.ID == scanDataTypeId);
}
}
}
}
UPD 例外: 「応答ストリームの処理中にエラーが発生しました。サーバーが次のメッセージで失敗しました:\r\nこの要求の処理中にエラーが発生しました。」ソース:System.Data.Services.Client ステータス コード:500
スタックトレース:
at System.Data.Services.Client.Xml.XmlAtomErrorReader.Read()
at System.Xml.XmlSubtreeReader.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XElement.ReadElementFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XElement.Load(XmlReader reader, LoadOptions options)
at System.Data.Services.Client.AtomParser.XElementBuilderCallback(XmlReader reader)
at System.Data.Services.Client.AtomParser.ParseCurrentEntry(AtomEntry& targetEntry)
at System.Data.Services.Client.AtomParser.Read()
at System.Data.Services.Client.AtomMaterializer.Read()
at System.Data.Services.Client.MaterializeAtom.MoveNextInternal()
at System.Data.Services.Client.MaterializeAtom.MoveNext()
at System.Linq.Enumerable.<CastIterator>d__b1`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at ClientDataServices.MailProcessingManagmentService.GetDocuments(Expression`1 filter) in D:\...\MailProcessingManagmentService.cs:line 41
at ClientDataServices.MailProcessingManager.GetEntries(Expression`1 predicate) in D:\...\MailProcessingManager.cs:line 24
at MailProcessingModule.ViewModels.MailProcessingViewModel.RefreshEntityHandler() in D:\...\MailProcessingViewModel.cs:line 113
at BaseModule.BaseGridViewModel`1.<>c__DisplayClass1a.<ListEntities>b__d(Object e) in D:\...\BaseGridViewModel.cs:line 178
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()