/// <summary> /// Adds the specified property to the type Properties. /// </summary> /// <param name="property">The property to add.</param> public void Add(QueryProperty property) { ExceptionUtilities.CheckArgumentNotNull(property, "property"); this.AssertNotReadOnly(); this.Properties.Add(property); }
private QueryScalarType GetDefaultQueryTypeForSpatial(PrimitiveDataType storeType, PrimitiveDataType modelType, SpatialDataType spatialDataType) { ExceptionUtilities.CheckArgumentNotNull(storeType, "storeType"); ExceptionUtilities.CheckArgumentNotNull(modelType, "modelType"); ExceptionUtilities.CheckArgumentNotNull(spatialDataType, "spatialDataType"); QueryMappedScalarTypeWithStructure spatialQDT; if (this.defaultQuerySpatialTypes.TryGetValue(spatialDataType, out spatialQDT)) { return(spatialQDT); } SpatialDataType spatialStoreType = storeType as SpatialDataType; SpatialDataType spatialModelType = modelType as SpatialDataType; var spatialMappedType = new QueryMappedScalarTypeWithStructure(spatialModelType, spatialStoreType, this.evaluationStrategy); this.defaultQuerySpatialTypes[spatialDataType] = spatialMappedType; spatialMappedType.Add(spatialModelType.Properties.Select(p => QueryProperty.Create(p.Name, this.GetDefaultQueryType(p.PropertyType)))); spatialMappedType.Add(spatialModelType.Methods); return(spatialMappedType.MakeReadOnly()); }
private QueryClrSpatialType GetDefaultQueryClrTypeForSpatial(SpatialDataType spatialDataType, Type clrType) { ExceptionUtilities.CheckArgumentNotNull(spatialDataType, "spatialDataType"); ExceptionUtilities.CheckArgumentNotNull(clrType, "clrType"); QueryClrSpatialType spatialClrType; if (this.defaultQueryClrSpatialTypes.TryGetValue(spatialDataType, out spatialClrType)) { return(spatialClrType); } spatialClrType = new QueryClrSpatialType(clrType, this.evaluationStrategy); this.defaultQueryClrSpatialTypes[spatialDataType] = spatialClrType; this.clrTypeToQueryScalarTypeMap[clrType] = spatialClrType; // wire-up inheritance based on CLR types var derivedTypes = clrType.GetAssembly().GetTypes().Where(t => t.IsSubclassOf(clrType)).ToList(); foreach (var derivedType in derivedTypes) { // only add types which are in EDM PrimitiveDataType edmType; if (this.TryGetEdmDataType(derivedType, out edmType)) { spatialClrType.DerivedTypes.Add((QueryClrSpatialType)this.GetDefaultQueryScalarType(derivedType)); } } spatialClrType.Add(spatialDataType.Properties.Select(p => QueryProperty.Create(p.Name, this.GetDefaultQueryType(p.PropertyType)))); spatialClrType.Add(spatialDataType.Methods); return(spatialClrType.MakeReadOnly()); }
/// <summary> /// Initializes a new instance of the QueryGroupingType class. /// </summary> /// <param name="keyType">Type of the grouping key.</param> /// <param name="elementType">Type of the grouping element.</param> /// <param name="evaluationStrategy">Evaluation strategy.</param> public QueryGroupingType(QueryType keyType, QueryType elementType, IQueryEvaluationStrategy evaluationStrategy) : base(evaluationStrategy) { this.Key = QueryProperty.Create("Key", keyType); this.elementType = elementType; QueryCollectionType collectionType = elementType.CreateCollectionType(); this.Elements = QueryProperty.Create("Elements", collectionType); this.AddProperties(new[] { this.Key, this.Elements }); this.MakeReadOnly(); }
/// <summary> /// Determines whether the property is a Navigation one or not /// </summary> /// <param name="property">Property to determine its type</param> /// <returns>true if its a navigation or false if its not</returns> public static bool IsNavigationProperty(this QueryProperty property) { var collection = property.PropertyType as QueryCollectionType; var entity = property.PropertyType as QueryEntityType; if (entity != null) { return(true); } else if (collection != null) { return(collection.ElementType is QueryEntityType); } return(false); }