internal void DisposeDataSource() { WebUtil.Dispose(this.metadataProvider); if (this.metadataProvider != this.queryProvider) { WebUtil.Dispose(this.queryProvider); } this.metadataProvider = null; this.queryProvider = null; this.dataService = null; }
internal DataServiceProviderWrapper(DataServiceCacheItem cacheItem, IDataServiceMetadataProvider metadataProvider, IDataServiceQueryProvider queryProvider, IDataService dataService) { this.metadata = cacheItem; this.metadataProvider = metadataProvider; this.queryProvider = queryProvider; this.dataService = dataService; this.operationWrapperCache = new Dictionary <string, OperationWrapper>(EqualityComparer <string> .Default); this.metadataProviderEdmModels = new Dictionary <DataServiceOperationContext, MetadataProviderEdmModel>(EqualityComparer <DataServiceOperationContext> .Default); this.models = new Dictionary <DataServiceOperationContext, IEdmModel>(EqualityComparer <DataServiceOperationContext> .Default); this.edmSchemaVersion = MetadataEdmSchemaVersion.Version1Dot0; this.containerNameCache = null; this.containerNamespaceCache = null; }
public override IQueryable <EntityType> GetEntitySet <EntityType>(string entitySetName) { IDataServiceMetadataProvider idsmp = this.CurrentDataSource; ResourceSet set; if (!idsmp.TryResolveResourceSet(entitySetName, out set)) { throw new DataServiceException("Could not find resource set with name '" + entitySetName + "'"); } IDataServiceQueryProvider idsqp = this.CurrentDataSource; return(idsqp.GetQueryRootForResourceSet(set).OfType <EntityType>()); }
/// <summary> /// Convert Late Bound Expression to CLR Expression /// </summary> /// <param name="ex">The Expression</param> /// <param name="provider">The IDSQP provider instance</param> /// <returns>The converted expression with no latebound methods</returns> public static Expression ToClrExpression(Expression ex, IDataServiceQueryProvider provider) { if (OpenTypeMethodsImplementation == null) { OpenTypeMethodsImplementation = new DefaultOpenTypeMethodsImplementation(); } if (DSPMethodsImplementation == null) { DSPMethodsImplementation = new DefaultDSPMethodsImplementation(); } OpenTypeMethodsImplementation.QueryProvider = provider; DSPMethodsImplementation.QueryProvider = provider; LateBoundExpressionVisitor visitor = new LateBoundExpressionVisitor(OpenTypeMethodsImplementation, DSPMethodsImplementation); return visitor.Visit(ex); }
/// <summary> /// Convert Late Bound Expression to CLR Expression /// </summary> /// <param name="ex">The Expression</param> /// <param name="provider">The IDSQP provider instance</param> /// <returns>The converted expression with no latebound methods</returns> public static Expression ToClrExpression(Expression ex, IDataServiceQueryProvider provider) { if (OpenTypeMethodsImplementation == null) { OpenTypeMethodsImplementation = new DefaultOpenTypeMethodsImplementation(); } if (DSPMethodsImplementation == null) { DSPMethodsImplementation = new DefaultDSPMethodsImplementation(); } OpenTypeMethodsImplementation.QueryProvider = provider; DSPMethodsImplementation.QueryProvider = provider; LateBoundExpressionVisitor visitor = new LateBoundExpressionVisitor(OpenTypeMethodsImplementation, DSPMethodsImplementation); return(visitor.Visit(ex)); }
public object[] GetSkipToken(IDataServiceQueryProvider dataServiceQueryPovider) { if (this.lastObject != null) { if (this.lastObject.GetType() == typeof(int)) { return(new object[] { -1 }); } object resource = this.lastObject; IExpandedResult expandedResult = resource as IExpandedResult; if (expandedResult != null) { resource = expandedResult.ExpandedElement; } IEnumerable <string> keyPropertyNames = this.IsReflectableResourceType ? new string[] { "ID" } : this.resourceType.KeyProperties.Select(property => property.Name); ProjectedWrapper projectedWrapper = resource as ProjectedWrapper; if (projectedWrapper != null) { return(keyPropertyNames.Select(propertyName => projectedWrapper.GetProjectedPropertyValue(propertyName)).ToArray()); } else if (dataServiceQueryPovider != null) { return(keyPropertyNames.Select(propertyName => dataServiceQueryPovider.GetPropertyValue(resource, this.resourceType.Properties.Single(p => p.Name == propertyName))).ToArray()); } else { return(keyPropertyNames.Select(propertyName => resource.GetType().GetProperty(propertyName).GetValue(resource, null)).ToArray()); } } return(new Random().Next() % 2 == 0 ? null : new object[0]); }
public CustomRowBasedContext() { if (preserveChanges == false || customers == null) { provider = null; queryProvider = null; Debug.Assert((customers == null && orders == null) || (customers != null && orders != null), "Either the data must be populated or not"); customers = new List<RowEntityTypeWithIDAsKey>(); orders = new List<RowEntityTypeWithIDAsKey>(); products = new List<RowEntityTypeWithIDAsKey>(); regions = new List<RowEntityTypeWithIDAsKey>(); orderDetails = new List<RowEntityType>(); memberCustomers = new List<RowEntityTypeWithIDAsKey>(); memberOrders = new List<RowEntityTypeWithIDAsKey>(); memberProducts = new List<RowEntityTypeWithIDAsKey>(); memberRegions = new List<RowEntityTypeWithIDAsKey>(); memberOrderDetails = new List<RowEntityType>(); // initialize data and metadata PopulateData(); if (CustomizeCustomers != null) { CustomizeCustomers(customers); } if (CustomizeOrders != null) { CustomizeOrders(orders); } provider = PopulateMetadata(this); queryProvider = (IDataServiceQueryProvider)provider; } }
public ODataServiceInterceptedQueryVisitor(IDataServiceQueryProvider dataServiceQueryProvider) { this._dataServiceQueryProvider = dataServiceQueryProvider; this._getValueReplacement = (o, rp) => this._dataServiceQueryProvider.GetPropertyValue(o, rp); this._typeIsReplacement = (o, rp) => this._dataServiceQueryProvider.GetResourceType(o).Name == rp.Name; }
public OpenTypeQueryProvider(IQueryProvider provider, IDataServiceQueryProvider dsp, string typeNamePropertyName) { this.innerProvider = provider; this.dsp = dsp; this.typeNamePropertyName = typeNamePropertyName; }
public static void ClearData() { CustomRowBasedContext.PreserveChanges = false; provider = null; queryProvider = null; customers = null; orders = null; regions = null; }
public DSPExpandProvider(IDataServiceQueryProvider queryProvider) { this.queryProvider = queryProvider; }
protected OpenTypeToClrConverter(IDataServiceQueryProvider dsp, string typeNamePropertyName) { this.Evaluator = new RuntimeEvaluator(); this.Provider = dsp; this.TypeNamePropertyName = typeNamePropertyName; }
/// <summary> /// Initializes a new instance of the DefaultDataServiceProviderMethodsReplacementStrategy class /// </summary> /// <param name="queryProvider">The current query provider</param> public DefaultDataServiceProviderMethodsReplacementStrategy(IDataServiceQueryProvider queryProvider) { this.queryProvider = queryProvider; }
public static Expression ToClrExpression(Expression input, IDataServiceQueryProvider dsp, string typeNamePropertyName) { return(new OpenTypeToClrConverter(dsp, typeNamePropertyName).Visit(input)); }
public PagingProvider(IDataServiceQueryProvider resourceQueryProvider) { this.resourceQueryProvider = resourceQueryProvider; }
private static Expression AccessProperty(Expression source, ResourceType resourceType, string propertyName, IDataServiceQueryProvider dataServiceQueryProvider) { source = UnwrapExpandedWrapper(source); Type projectedWrapperType = typeof(Microsoft.OData.Service.Internal.ProjectedWrapper); if (projectedWrapperType.IsAssignableFrom(source.Type)) { return(Expression.Call( source, projectedWrapperType.GetMethod("GetProjectedPropertyValue"), Expression.Constant(propertyName))); } else if (dataServiceQueryProvider != null) { return(Expression.Call( Expression.Constant(dataServiceQueryProvider), typeof(IDataServiceQueryProvider).GetMethod("GetPropertyValue"), source, Expression.Constant(resourceType.Properties.Single(p => p.Name == propertyName)))); } else { return(Expression.Property(Expression.Convert(source, resourceType.InstanceType), propertyName)); } }
public PagedQueryProvider(IDataServiceQueryProvider dataServiceQueryProvider, IQueryProvider provider, ResourceType resourceType, object[] continuationToken, CountManager countManager) : this(provider, resourceType, continuationToken, countManager) { this.dataServiceQueryProvider = dataServiceQueryProvider; }
/// <summary> /// Initializes a new instance of the RealisticOpenTypeMethodsReplacementStrategy class /// </summary> /// <param name="queryProvider">The current query provider</param> public RealisticOpenTypeMethodsReplacementStrategy(IDataServiceQueryProvider queryProvider) : base(queryProvider) { }
/// <summary> /// Initializes a new instance of the OpenTypeMethodsReplacementStrategy class /// </summary> /// <param name="queryProvider">The current query provider</param> protected OpenTypeMethodsReplacementStrategy(IDataServiceQueryProvider queryProvider) { this.QueryProvider = queryProvider; }
public static Expression ToClrExpression(Expression input, IDataServiceQueryProvider dsp, string typeNamePropertyName) { return new OpenTypeToClrConverter(dsp, typeNamePropertyName).Visit(input); }
public NonClrQueryProvider(IQueryProvider provider, IDataServiceQueryProvider dsp) { this.realProvider = provider; this.provider = dsp; }