public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context) { Thread t = new Thread(DoFetch); FetchTask task = new FetchTask(); task.ObjectType = objectType; task.Criteria = criteria; task.Context = context; t.Start(task); t.Join(); return task.Result; }
public DataPortalResult Fetch(Type objectType, object criteria, DataPortalContext context) { Thread t = new Thread(DoFetch); FetchTask task = new FetchTask(); task.ObjectType = objectType; task.Criteria = criteria; task.Context = context; t.Start(task); t.Join(); return(task.Result); }
void DoFetch(object state) { FetchTask task = null; try { task = state as FetchTask; if (task != null) { task.Result = Portal.Fetch(task.ObjectType, task.Criteria, task.Context); } } catch (Exception ex) { if (task != null) { task.ResultException = ex; } } }
public async Task <DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync) { var task = new FetchTask { ObjectType = objectType, Criteria = criteria, Context = context }; if (isSync) { DoFetch(task); } else { await Task.Factory.StartNew(DoFetch, task); } if (task.ResultException != null) { throw task.ResultException; } return(task.Result); }
public async Task<DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync) { var task = new FetchTask { ObjectType = objectType, Criteria = criteria, Context = context }; if (isSync) DoFetch(task); else await Task.Factory.StartNew(DoFetch, task); if (task.ResultException != null) throw task.ResultException; return task.Result; }
void DoFetch(object state) { FetchTask task = state as FetchTask; task.Result = Portal.Fetch(task.ObjectType, task.Criteria, task.Context); }
private void Visit( OptimizerContext context, ISelectionSet selectionSet, IObjectType objectType, FetchTask?parent) { if (!context.Processed.IsSupersetOf(selectionSet.Selections)) { IReadOnlyList <IFetchConfiguration> configurations = GetFetchConfigurations(objectType); var tasks = new List <FetchTask>(); FetchTask?task = null; foreach (IFetchConfiguration configuration in configurations) { if (configuration.CanHandleSelections( context.Operation, selectionSet, objectType, out IReadOnlyList <ISelection> handledSelections)) { var current = new FetchTask( new HashSet <ISelection>(handledSelections), configuration, parent?.Path.Push(parent) ?? ImmutableStack <FetchTask> .Empty, tasks); if (task is null || task.Selections.Count < handledSelections.Count) { task = current; } tasks.Add(current); } } if (task is not null) { tasks.Remove(task); foreach (ISelection handledSelection in task.Selections) { context.Processed.Add(handledSelection); } if (parent is null) { context.QueryPlan.Add(task); } else { parent.Children.Add(task); } parent = task; } } foreach (ISelection selection in selectionSet.Selections) { Visit(context, selection, parent); } }