public void OnReturn(IListRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) { return; } var idField = (Field)((handler.Row as IIdRow).IdField); var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = ColumnSelection.KeyOnly, IncludeColumns = new HashSet <string> { itemKeyField.PropertyName ?? itemKeyField.Name, thisKeyField.PropertyName ?? thisKeyField.Name } }; var enumerator = handler.Response.Entities.Cast <Row>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) { break; } enumerator = enumerator.Skip(1000); listRequest.Criteria = thisKeyCriteria.In( part.Select(x => idField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast <Row>() .ToLookup(x => thisKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = listFactory(); var matching = lookup[idField.AsObject(row).ToString()]; foreach (var x in matching) { list.Add(itemKeyField.AsObject(x)); } Target.AsObject(row, list); } } }
public void OnReturn(IListRequestHandler handler) { if (Target is null || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) { return; } var listHandler = handlerFactory.CreateHandler <IListRequestProcessor>(rowType); var listRequest = listHandler.CreateRequest(); listRequest.ColumnSelection = attr.ColumnSelection; listRequest.IncludeColumns = includeColumns; var enumerator = handler.Response.Entities.Cast <IRow>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) { break; } enumerator = enumerator.Skip(1000); listRequest.Criteria = foreignKeyCriteria.In( part.Select(x => masterKeyField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast <IRow>() .ToLookup(x => foreignKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = rowListFactory(); var matching = lookup[masterKeyField.AsObject(row).ToString()]; foreach (var x in matching) { list.Add(x); } Target.AsObject(row, list); } } }
public void OnReturn(IListRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) return; var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = this.attr.ColumnSelection, IncludeColumns = this.includeColumns }; var enumerator = handler.Response.Entities.Cast<Row>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) break; enumerator = enumerator.Skip(1000); listRequest.Criteria = foreignKeyCriteria.In( part.Select(x => masterKeyField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast<Row>() .ToLookup(x => foreignKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = rowListFactory(); var matching = lookup[masterKeyField.AsObject(row).ToString()]; foreach (var x in matching) list.Add(x); Target.AsObject(row, list); } } }
public void OnReturn(IListRequestHandler handler) { if (ReferenceEquals(null, Target) || !handler.AllowSelectField(Target) || !handler.ShouldSelectField(Target) || handler.Response.Entities.IsEmptyOrNull()) return; var idField = (Field)((handler.Row as IIdRow).IdField); var listHandler = listHandlerFactory(); var listRequest = new ListRequest { ColumnSelection = ColumnSelection.KeyOnly, IncludeColumns = new HashSet<string> { itemKeyField.PropertyName ?? itemKeyField.Name, thisKeyField.PropertyName ?? thisKeyField.Name } }; var enumerator = handler.Response.Entities.Cast<Row>(); while (true) { var part = enumerator.Take(1000); if (!part.Any()) break; enumerator = enumerator.Skip(1000); listRequest.Criteria = thisKeyCriteria.In( part.Select(x => idField.AsObject(x))) & filterCriteria; IListResponse response = listHandler.Process( handler.Connection, listRequest); var lookup = response.Entities.Cast<Row>() .ToLookup(x => thisKeyField.AsObject(x).ToString()); foreach (var row in part) { var list = listFactory(); var matching = lookup[idField.AsObject(row).ToString()]; foreach (var x in matching) list.Add(itemKeyField.AsObject(x)); Target.AsObject(row, list); } } }