public OeQueryContext CreateQueryContext(ODataUri odataUri, int pageSize, bool navigationNextLink, OeMetadataLevel metadataLevel) { List <OeParseNavigationSegment> navigationSegments = null; if (odataUri.Path.LastSegment is KeySegment || odataUri.Path.LastSegment is NavigationPropertySegment) { navigationSegments = new List <OeParseNavigationSegment>(); ODataPathSegment previousSegment = null; foreach (ODataPathSegment segment in odataUri.Path) { if (segment is NavigationPropertySegment navigationSegment) { navigationSegments.Add(new OeParseNavigationSegment(navigationSegment, null)); } else if (segment is KeySegment) { IEdmEntitySet previousEntitySet; var keySegment = segment as KeySegment; navigationSegment = null; if (previousSegment is EntitySetSegment) { var previousEntitySetSegment = previousSegment as EntitySetSegment; previousEntitySet = previousEntitySetSegment.EntitySet; } else if (previousSegment is NavigationPropertySegment) { navigationSegment = previousSegment as NavigationPropertySegment; previousEntitySet = (IEdmEntitySet)navigationSegment.NavigationSource; } else { throw new InvalidOperationException("invalid segment"); } FilterClause keyFilter = CreateFilterClause(previousEntitySet, keySegment.Keys); navigationSegments.Add(new OeParseNavigationSegment(navigationSegment, keyFilter)); } previousSegment = segment; } } if (pageSize > 0) { odataUri.Top = pageSize; IEdmEntityType edmEntityType = GetEntityType(odataUri.Path, navigationSegments); odataUri.OrderBy = OeSkipTokenParser.GetUniqueOrderBy(_edmModel, edmEntityType, odataUri.OrderBy, odataUri.Apply); } var entitySetSegment = (EntitySetSegment)odataUri.Path.FirstSegment; IEdmEntitySet entitySet = entitySetSegment.EntitySet; Db.OeEntitySetAdapter entitySetAdapter = _dataAdapter.EntitySetAdapters.FindByEntitySetName(entitySet.Name); bool isCountSegment = odataUri.Path.LastSegment is CountSegment; return(new OeQueryContext(_edmModel, odataUri, entitySet, navigationSegments, isCountSegment, pageSize, navigationNextLink, _dataAdapter.IsDatabaseNullHighestValue, metadataLevel, entitySetAdapter)); }
public static Db.OeEntitySetAdapter GetEntitySetAdapter(this IEdmModel edmModel, IEdmEntitySet entitySet) { Db.OeEntitySetAdapter entitySetAdapter = edmModel.GetAnnotationValue <Db.OeEntitySetAdapter>(entitySet); if (entitySetAdapter == null) { entitySetAdapter = edmModel.GetEdmModel(entitySet).GetAnnotationValue <Db.OeEntitySetAdapter>(entitySet); } return(entitySetAdapter); }
public OeQueryContext CreateQueryContext(ODataUri odataUri, OeMetadataLevel metadataLevel, Type returnClrType) { String entitySetName = _dataAdapter.EntitySetMetaAdapters.FindByClrType(returnClrType).EntitySetName; IEdmEntitySet entitySet = _model.FindDeclaredEntitySet(entitySetName); OePropertyAccessor[] accessors = OePropertyAccessor.CreateFromType(returnClrType, entitySet); Db.OeEntitySetAdapter entitySetAdapter = _dataAdapter.GetEntitySetAdapter(entitySet.Name); return(new OeQueryContext(_model, odataUri, entitySet, null, false, 0, false, _dataAdapter.IsDatabaseNullHighestValue, metadataLevel, ref entitySetAdapter) { EntryFactory = OeEntryFactory.CreateEntryFactory(entitySet, accessors), }); }
public static void SetEntitySetAdapter(this IEdmModel edmModel, IEdmEntitySet entitySet, Db.OeEntitySetAdapter entitySetAdapter) { edmModel.SetAnnotationValue(entitySet, entitySetAdapter); }
protected abstract OeAsyncEnumerator ExecuteReader(Object dataContext, String sql, IReadOnlyList <KeyValuePair <String, Object> > parameters, OeEntitySetAdapter entitySetAdapter);
public virtual OeAsyncEnumerator ExecuteProcedureReader(Object dataContext, String operationName, IReadOnlyList <KeyValuePair <String, Object> > parameters, OeEntitySetAdapter entitySetAdapter) { String procedureName = GetProcedureName(dataContext, operationName, parameters); return(ExecuteReader(dataContext, procedureName, parameters, entitySetAdapter)); }
public virtual OeAsyncEnumerator ExecuteFunctionReader(Object dataContext, String operationName, IReadOnlyList <KeyValuePair <String, Object> > parameters, OeEntitySetAdapter entitySetAdapter) { String sql = GetSql(dataContext, parameters); String functionName = GetOperationCaseSensitivityName(operationName, GetDefaultSchema(dataContext)); return(ExecuteReader(dataContext, "select * from " + functionName + sql.ToString(), parameters, entitySetAdapter)); }