コード例 #1
0
        private void PopulateNavigations(EntitySetDataRow row, QueryStructuralValue instance)
        {
            var                 entityInstance = instance as QueryEntityValue;
            EntitySetData       entitySetData  = row.Parent;
            EntityContainerData containerData  = entitySetData.Parent;

            foreach (AssociationSet associationSet in containerData.EntityContainer.AssociationSets)
            {
                foreach (var fromSetEnd in associationSet.Ends.Where(e => e.EntitySet == entitySetData.EntitySet))
                {
                    var fromEntityType = fromSetEnd.AssociationEnd.EntityType;
                    if (!row.EntityType.IsKindOf(fromEntityType))
                    {
                        continue;
                    }

                    var toSetEnd = associationSet.GetOtherEnd(fromSetEnd);

                    this.PopulateNavigateResult(row, entityInstance, associationSet, fromSetEnd, toSetEnd);

                    // if Navigation property exists, populate it as well
                    var navProp = row.EntityType.AllNavigationProperties.SingleOrDefault(p => p.Association == associationSet.AssociationType &&
                                                                                         p.ToAssociationEnd == toSetEnd.AssociationEnd);
                    if (navProp != null)
                    {
                        instance.SetValue(navProp.Name, entityInstance.GetNavigateResult(navProp.Association, navProp.ToAssociationEnd));
                    }
                }
            }
        }
コード例 #2
0
        private void CreateRelationships(
            EntityContainerData data,
            ref int createdEntitiesCount,
            ref int createdAssociationsCount)
        {
            List <RelationshipDescription> relationshipsToCreate;
            List <KeyValuePair <EntitySet, EntityType> > entitiesToCreateInCurrentBatch;
            int loopCount = 0;

            while (this.GetRelationshipsAndEntitiesToCreate(out relationshipsToCreate, out entitiesToCreateInCurrentBatch))
            {
                loopCount++;

                // there are times when relationships are unable to be created for particular entity type graphs
                // in these situations this check guards against running infinitely long, adding 20
                // ensures that all models get at least 100 loops to generate relationship data, otherwise this
                // guard might be too low
                if (loopCount > ((this.relationshipSelectors.Count * 4) + 20))
                {
                    throw new TaupoInvalidOperationException("Specified relationship requirements cannot be met. Make sure capacity selectors don't contradict each other.");
                }

                this.PopulateAssociationSetRows(data, relationshipsToCreate);
                createdAssociationsCount += relationshipsToCreate.Count;

                foreach (var setTypePair in entitiesToCreateInCurrentBatch)
                {
                    EntitySetDataRow r = this.PopulateNewEntitySetRow(data, setTypePair.Key, setTypePair.Value);
                    createdEntitiesCount++;
                    this.ConsiderCandidateForRelationships(r);
                }
            }
        }
コード例 #3
0
 private void PopulateAssociationSetRows(EntityContainerData data, IEnumerable <RelationshipDescription> relationshipsToCreate)
 {
     foreach (RelationshipDescription rd in relationshipsToCreate)
     {
         AssociationSetDataRow row = data[rd.AssociationSet].AddNewRow();
         row.SetRoleKey(rd.ToRoleName, rd.To);
         row.SetRoleKey(rd.FromRoleName, rd.From);
     }
 }
コード例 #4
0
ファイル: EntitySetData.cs プロジェクト: larsenjo/odata.net
        internal EntitySetData(EntityContainerData parent, EntitySet entitySet)
        {
            this.EntitySet = entitySet;
            this.Parent = parent;
            this.Rows = new List<EntitySetDataRow>();

            var possibleEntityTypes = this.GetAllNonAbstractTypesOfKind(entitySet.EntityType).ToList();
            if (possibleEntityTypes.Count == 1)
            {
                this.singleEntityType = possibleEntityTypes[0];
            }
        }
コード例 #5
0
        private EntitySetDataRow PopulateEntitySetRow(EntityContainerData data, EntitySet entitySet, EntityType entityType, IEnumerable <NamedValue> entityData)
        {
            EntitySetDataRow row = data[entitySet].AddNewRowOfType(entityType);

            foreach (NamedValue namedValue in entityData)
            {
                row.SetValue(namedValue.Name, namedValue.Value);
            }

            this.entitySetAndTypeSelector.IncrementCount(entitySet, entityType);

            return(row);
        }
コード例 #6
0
        private void ConvertEntityProperty(SerializableEntity entity, EntityContainerData data, Dictionary <SerializableEntity, EntitySetDataRow> rowMap)
        {
            var row = rowMap[entity];

            foreach (var prop in entity.Properties)
            {
                var relatedRows = prop.Value as IEnumerable <SerializableEntity>;
                var relatedRow  = prop.Value as SerializableEntity;
                if (relatedRows == null)
                {
                    if (relatedRow != null)
                    {
                        relatedRows = new[] { relatedRow };
                    }
                }

                if (relatedRows != null)
                {
                    var type    = row.EntityType;
                    var navprop = type.AllNavigationProperties.Single(c => c.Name == prop.Name);

                    // handle MEST scenario where there are multiple association sets corresponding to a navigation property
                    var assocSets = data.EntityContainer.AssociationSets.Where(c => c.AssociationType == navprop.Association);
                    var assocSet  = assocSets.Single(set => set.Ends.Any(end => end.AssociationEnd == navprop.FromAssociationEnd && end.EntitySet.Name == entity.EntitySetName));

                    var associationSetData = data[assocSet];

                    foreach (var rr in relatedRows)
                    {
                        if (!associationSetData.Rows.Where(c => c.GetRoleKey(navprop.FromAssociationEnd.RoleName) == row.Key && c.GetRoleKey(navprop.ToAssociationEnd.RoleName) == rowMap[rr].Key).Any())
                        {
                            var associationRow = associationSetData.AddNewRow();
                            associationRow.SetRoleKey(navprop.FromAssociationEnd.RoleName, row.Key);
                            associationRow.SetRoleKey(navprop.ToAssociationEnd.RoleName, rowMap[rr].Key);
                        }
                    }
                }
                else
                {
                    // it could still be a null navigation property
                    var navigation = row.EntityType.AllNavigationProperties.SingleOrDefault(p => p.Name == prop.Name);
                    if (navigation == null)
                    {
                        var namedValue = this.Convert(prop);
                        row.SetValue(namedValue.Name, namedValue.Value);
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Factory method that creates a new instance of the QueryRepository.
        /// </summary>
        /// <param name="entityModelSchema">Entity Model Schema</param>
        /// <param name="queryTypeLibrary">Query Type Library</param>
        /// <param name="entityContainerData">Entity Container Data</param>
        /// <returns>An instance of the QueryRepository class.</returns>
        public virtual QueryRepository CreateQueryRepository(EntityModelSchema entityModelSchema, QueryTypeLibrary queryTypeLibrary, EntityContainerData entityContainerData)
        {
            this.RootDataTypes = new Dictionary<string, QueryStructuralType>();

            this.BuildPrimitiveTypes(queryTypeLibrary);
            this.BuildRootQueriesAndTypes(entityModelSchema, queryTypeLibrary);

            var dataSet = this.DataSetBuilder.Build(this.RootDataTypes, entityContainerData);

            this.BuildConstants(queryTypeLibrary, dataSet);

            QueryRepository repository = new QueryRepository(queryTypeLibrary, this.RootQueries, this.Constants, this.PrimitiveTypes, this.RootDataTypes, dataSet);

            return repository;
        }
コード例 #8
0
        private void PopulateNavigateResult(EntitySetDataRow row, QueryEntityValue entityInstance, AssociationSet associationSet, AssociationSetEnd fromSetEnd, AssociationSetEnd toSetEnd)
        {
            EntityContainerData containerData = row.Parent.Parent;
            var associationSetData            = containerData.GetAssociationSetData(associationSet.Name);

            var targetInstanceLookup = this.rowInstances[toSetEnd.EntitySet.Name];

            var associatedObjects = associationSetData.Rows
                                    .Where(r => r.GetRoleKey(fromSetEnd.AssociationEnd.RoleName).Equals(row.Key))
                                    .Select(r => targetInstanceLookup[r.GetRoleKey(toSetEnd.AssociationEnd.RoleName)])
                                    .ToArray();

            var toEntityType      = toSetEnd.AssociationEnd.EntityType;
            var toQueryEntityType = this.GetQueryType(toSetEnd.EntitySet.Name, toEntityType);

            if (toSetEnd.AssociationEnd.Multiplicity == EndMultiplicity.Many)
            {
                var collectionType  = toQueryEntityType.CreateCollectionType();
                var collectionValue = collectionType.CreateCollectionWithValues(associatedObjects);
                entityInstance.SetNavigateResult(associationSet.AssociationType, toSetEnd.AssociationEnd, collectionValue);
            }
            else
            {
                if (associatedObjects.Length == 0)
                {
                    entityInstance.SetNavigateResult(associationSet.AssociationType, toSetEnd.AssociationEnd, toQueryEntityType.NullValue);
                }
                else
                {
                    if (associatedObjects.Length != 1)
                    {
                        var debugAssociatedValues = string.Join("," + Environment.NewLine, associatedObjects.Select(ao => ao.ToString()));
                        throw new TaupoInfrastructureException(
                                  string.Format(
                                      CultureInfo.InvariantCulture,
                                      "Found {0} associated objects for {1}.{2}, on Entity Instance {3} associated Objects = {4}",
                                      associatedObjects.Length,
                                      associationSet.AssociationType.FullName,
                                      fromSetEnd.AssociationEnd.RoleName,
                                      entityInstance,
                                      debugAssociatedValues));
                    }

                    var targetInstance = associatedObjects.Single();
                    entityInstance.SetNavigateResult(associationSet.AssociationType, toSetEnd.AssociationEnd, targetInstance);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Adds seed data to the <see cref="EntityContainerData"/> created by this instance by
        /// calling <see cref="TryPopulateNextData"/>.
        /// </summary>
        /// <param name="entitySet">The <see cref="EntitySet"/> to which the new seed instance belongs.</param>
        /// <param name="entityType">The <see cref="EntityType"/> of the new seed instance.</param>
        /// <param name="entityData">A collection of <see cref="NamedValue"/>s that describe the structural data of the instance.</param>
        /// <returns>The <see cref="EntityDataKey"/> that describes the seed instance.</returns>
        public EntityDataKey Seed(EntitySet entitySet, EntityType entityType, IEnumerable <NamedValue> entityData)
        {
            this.CreateEntitySetAndTypeSelectorIfNull();
            this.CreateRelationshipSelectorsIfNull();

            if (this.seedData == null)
            {
                this.seedData = new EntityContainerData(this.entityContainer);
            }

            var seedRow = this.PopulateEntitySetRow(this.seedData, entitySet, entityType, entityData);

            this.ConsiderCandidateForRelationships(seedRow);

            return(seedRow.Key);
        }
コード例 #10
0
        /// <summary>
        /// Tries to get next data to upload.
        /// </summary>
        /// <param name="data">The data to upload.</param>
        /// <returns>True if there is a data for upload, false otherwise.</returns>
        public virtual bool TryPopulateNextData(out EntityContainerData data)
        {
            ExceptionUtilities.CheckObjectNotNull(this.StructuralDataServices, "StructuralGenerators cannot be null.");

            this.CreateEntitySetAndTypeSelectorIfNull();
            this.CreateRelationshipSelectorsIfNull();

            if (this.seedData != null)
            {
                data          = this.seedData;
                this.seedData = null;
            }
            else
            {
                data = new EntityContainerData(this.EntityContainer);
            }

            int createdEntitiesCount = 0, createdAssociationsCount = 0;

            this.CreateRelationships(data, ref createdEntitiesCount, ref createdAssociationsCount);

            EntitySet  entitySet;
            EntityType entityType;

            while (this.GetNextEntitySetAndTypeToCreate(out entitySet, out entityType))
            {
                EntitySetDataRow row = this.PopulateNewEntitySetRow(data, entitySet, entityType);
                createdEntitiesCount++;
                this.ConsiderCandidateForRelationships(row);

                this.CreateRelationships(data, ref createdEntitiesCount, ref createdAssociationsCount);

                if (createdEntitiesCount >= this.ThresholdForNumberOfEntities && this.ThresholdForNumberOfEntities != -1)
                {
                    break;
                }
            }

            if (this.ReferentialConstraintsResolver != null)
            {
                this.ReferentialConstraintsResolver.ResolveReferentialConstraints(data);
            }

            return(createdEntitiesCount > 0 || createdAssociationsCount > 0);
        }
コード例 #11
0
ファイル: InanimateData.cs プロジェクト: Cloudxtreme/NetMud
        /// <summary>
        /// Fills a data object with data from a data row
        /// </summary>
        /// <param name="dr">the data row to fill from</param>
        public override void Fill(DataRow dr)
        {
            ID          = DataUtility.GetFromDataRow <long>(dr, "ID");
            Created     = DataUtility.GetFromDataRow <DateTime>(dr, "Created");
            LastRevised = DataUtility.GetFromDataRow <DateTime>(dr, "LastRevised");
            Name        = DataUtility.GetFromDataRow <string>(dr, "Name");

            string mobileContainerJson = DataUtility.GetFromDataRow <string>(dr, "MobileContainers");

            dynamic mobileContainers = JsonConvert.DeserializeObject(mobileContainerJson);

            foreach (dynamic mobileContainer in mobileContainers)
            {
                var newContainer = new EntityContainerData <IMobile>();
                newContainer.CapacityVolume = mobileContainer.CapacityVolume;
                newContainer.CapacityWeight = mobileContainer.CapacityWeight;
                newContainer.Name           = mobileContainer.Name;

                MobileContainers.Add(newContainer);
            }

            string inanimateContainerJson = DataUtility.GetFromDataRow <string>(dr, "InanimateContainers");

            dynamic inanimateContainers = JsonConvert.DeserializeObject(inanimateContainerJson);

            foreach (dynamic inanimateContainer in inanimateContainers)
            {
                var newContainer = new EntityContainerData <IInanimate>();
                newContainer.CapacityVolume = inanimateContainer.CapacityVolume;
                newContainer.CapacityWeight = inanimateContainer.CapacityWeight;
                newContainer.Name           = inanimateContainer.Name;

                InanimateContainers.Add(newContainer);
            }

            string internalCompositionJson = DataUtility.GetFromDataRow <string>(dr, "InternalComposition");

            InternalComposition = DeserializeInternalCompositions(internalCompositionJson);

            Model = new DimensionalModel(dr);
        }
コード例 #12
0
        /// <summary>
        /// Converts the serializable container (WCF proxy classes) into EntityContainerData.
        /// </summary>
        /// <param name="modelSchema">The model schema.</param>
        /// <param name="serializableContainer">The serializable container.</param>
        /// <returns>
        /// Instance of <see cref="EntityContainerData"/>
        /// </returns>
        public EntityContainerData Convert(EntityModelSchema modelSchema, SerializableContainer serializableContainer)
        {
            ExceptionUtilities.CheckArgumentNotNull(modelSchema, "modelSchema");
            ExceptionUtilities.CheckArgumentNotNull(serializableContainer, "serializableContainer");

            var container = modelSchema.EntityContainers.Single(c => c.Name == serializableContainer.EntityContainerName);
            var data = new EntityContainerData(container);
            var rowMap = new Dictionary<SerializableEntity, EntitySetDataRow>();

            foreach (var entity in serializableContainer.Entities)
            {
                var setData = data.GetEntitySetData(entity.EntitySetName);
                EntitySetDataRow row;
                if (entity.Streams != null)
                {
                    var entityType = modelSchema.EntityTypes.Single(t => t.FullName == entity.EntityType);
                    var rowWithStreams = new EntitySetDataRowWithStreams(setData, entityType);
                    row = rowWithStreams;
                    setData.Rows.Add(row);

                    foreach (var stream in entity.Streams)
                    {
                        rowWithStreams.Streams.Add(ConvertStreamData(stream));
                    }
                }
                else
                {
                    row = setData.AddNewRowOfType(entity.EntityType);
                }

                rowMap.Add(entity, row);
            }

            foreach (var entity in serializableContainer.Entities)
            {
                this.ConvertEntityProperty(entity, data, rowMap);
            }

            return data;
        }
コード例 #13
0
        /// <summary>
        /// Converts the serializable container (WCF proxy classes) into EntityContainerData.
        /// </summary>
        /// <param name="modelSchema">The model schema.</param>
        /// <param name="serializableContainer">The serializable container.</param>
        /// <returns>
        /// Instance of <see cref="EntityContainerData"/>
        /// </returns>
        public EntityContainerData Convert(EntityModelSchema modelSchema, SerializableContainer serializableContainer)
        {
            ExceptionUtilities.CheckArgumentNotNull(modelSchema, "modelSchema");
            ExceptionUtilities.CheckArgumentNotNull(serializableContainer, "serializableContainer");

            var container = modelSchema.EntityContainers.Single(c => c.Name == serializableContainer.EntityContainerName);
            var data      = new EntityContainerData(container);
            var rowMap    = new Dictionary <SerializableEntity, EntitySetDataRow>();

            foreach (var entity in serializableContainer.Entities)
            {
                var setData = data.GetEntitySetData(entity.EntitySetName);
                EntitySetDataRow row;
                if (entity.Streams != null)
                {
                    var entityType     = modelSchema.EntityTypes.Single(t => t.FullName == entity.EntityType);
                    var rowWithStreams = new EntitySetDataRowWithStreams(setData, entityType);
                    row = rowWithStreams;
                    setData.Rows.Add(row);

                    foreach (var stream in entity.Streams)
                    {
                        rowWithStreams.Streams.Add(ConvertStreamData(stream));
                    }
                }
                else
                {
                    row = setData.AddNewRowOfType(entity.EntityType);
                }

                rowMap.Add(entity, row);
            }

            foreach (var entity in serializableContainer.Entities)
            {
                this.ConvertEntityProperty(entity, data, rowMap);
            }

            return(data);
        }
コード例 #14
0
 /// <summary>
 /// Builds the <see cref="QueryDataSet"/> from the specified container data and query queryRepository.
 /// </summary>
 /// <param name="rootDataTypeMap">The collection of rootDataTypes used to build the data set.</param>
 /// <param name="entityContainerData">Entity Container Data that contains the information to be used in the QueryDataSet</param>
 /// <returns>
 /// Instance of <see cref="QueryDataSet"/> with data populated from the containerData
 /// </returns>
 public override IQueryDataSet Build(IDictionary <string, QueryStructuralType> rootDataTypeMap, EntityContainerData entityContainerData)
 {
     return(this.BuildQueryDataSetFunc(rootDataTypeMap, entityContainerData));
 }
コード例 #15
0
 /// <summary>
 /// Factory method that creates a new instance of the QueryRepository.
 /// </summary>
 /// <param name="entityModelSchema">Entity Model Schema</param>
 /// <param name="queryTypeLibrary">Query Type Library</param>
 /// <param name="entityContainerData">Entity Container Data</param>
 /// <returns>An instance of the QueryRepository class.</returns>
 public override QueryRepository CreateQueryRepository(EntityModelSchema entityModelSchema, QueryTypeLibrary queryTypeLibrary, EntityContainerData entityContainerData)
 {
     return this.CreateRepositoryFunc(entityModelSchema, queryTypeLibrary, entityContainerData);
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstraintsResolver"/> class.
 /// </summary>
 /// <param name="data">The entity container data to resolve referential constraints.</param>
 public ConstraintsResolver(EntityContainerData data)
 {
     this.data = data;
     this.Initialize();
 }
コード例 #17
0
        /// <summary>
        /// The configuration of these dependencies will be called from other testcase hierarchies that do not inherit from this class.
        /// This method can be used in such hierarchies.
        /// </summary>
        /// <param name="container">container on which to register impelemntation dependencies</param>
        public static void ConfigureDependenciesHelper(DependencyInjectionContainer container)
        {
            container.Register <IClrTypeReferenceResolver, StronglyTypedClrTypeReferenceResolver>();
            container.Register <IObjectLayerCodeGenerator, StronglyTypedObjectLayerCodeGenerator>();
            container.Register <IQueryEvaluationStrategy, ClrQueryEvaluationStrategy>();
            container.Register <IModelGenerator, ODataV2ModelGenerator>();
            container.Register <IWorkspaceBuilder, ODataWorkspaceBuilder>(); // Is this also needed , since we register Custom Resolver below
            container.Register <IQueryRepositoryBuilder, AstoriaQueryRepositoryBuilderBase>();
            container.Register <IQueryDataSetBuilder, ODataQueryDataSetBuilder>();

            container.Register <IResourceLookup, AssemblyResourceLookup>();
            container.Register <IStringResourceVerifier, StringResourceVerifier>();
            container.Register <IQueryScalarValueToClrValueComparer, QueryScalarValueToClrValueComparer>();
            container.Register <IQueryExpressionEvaluator, LinqToAstoriaEvaluator>();
            container.Register <IClientCodeLayerGenerator, PocoClientCodeLayerGenerator>();

            container.Register <ILinqToAstoriaQueryEvaluationStrategy, LinqToAstoriaClrQueryEvaluationStrategy>();
            container.Register <IPrimitiveDataTypeResolver, NullPrimitiveDataTypeResolver>();
            container.Register <ILinqResultComparerContextAdapter, ODataObjectResultComparerContextAdapter>();

            container.Register <ISpatialClrTypeResolver, SpatialClrTypeResolver>();
            container.Register <ISpatialDataTypeDefinitionResolver, SpatialDataTypeDefinitionResolver>();
            container.Register <IPayloadTransformFactory, ODataLibPayloadTransformFactory>();

            container.RegisterCustomResolver(
                typeof(ODataTestWorkspace),
                t =>
            {
                var builder        = container.Resolve <ODataWorkspaceBuilder>();
                var modelGenerator = container.Resolve <IModelGenerator>();
                var workspace      = builder.BuildWorkspace(modelGenerator.GenerateModel());

                return(workspace);
            });

            container.RegisterCustomResolver(
                typeof(IQueryTypeLibraryBuilder),
                queryTypeLibBuilderResolver =>
            {
                var queryEvaluationStrategy = container.Resolve <ILinqToAstoriaQueryEvaluationStrategy>();
                var primitiveTypeResolver   = container.Resolve <IPrimitiveDataTypeResolver>();
                return(new AstoriaQueryTypeLibraryBuilder(queryEvaluationStrategy, primitiveTypeResolver, new EdmDataTypeResolver()));
            });

            // IQueryDataSet is built by the repository builder
            container.RegisterCustomResolver(
                typeof(IQueryDataSet),
                t =>
            {
                var repository = container.Resolve <QueryRepository>();
                return(repository.DataSet);
            });

            container.RegisterCustomResolver(
                typeof(QueryTypeLibrary),
                queryTypeLib =>
            {
                var workspace = container.Resolve <ODataTestWorkspace>();
                var queryTypeLibraryBuilder = container.Resolve <IQueryTypeLibraryBuilder>();
                var queryTypeLibrary        = queryTypeLibraryBuilder.BuildLibraryWithoutClrTypeMapping(workspace.ConceptualModel);
                if (workspace.ObjectLayerAssembly != null)
                {
                    queryTypeLibrary.UpdateClrTypeMapping(new[] { workspace.ObjectLayerAssembly });
                }

                return(queryTypeLibrary);
            });

            container.RegisterCustomResolver(
                typeof(EntityContainerData),
                t =>
            {
                // TODO: All Query tests fail when there is actual data, for now starting with empty data
                var workspace            = container.Resolve <ODataTestWorkspace>();
                EntityContainerData data = null;
                data = new EntityContainerData(workspace.ConceptualModel.GetDefaultEntityContainer());

                //var dataPopulationDriver = container.Resolve<EntityContainerDataPopulationDriver>();
                //dataPopulationDriver.ThresholdForNumberOfEntities = -1;
                //dataPopulationDriver.EntityContainer = workspace.ConceptualModel.GetDefaultEntityContainer();
                //dataPopulationDriver.TryPopulateNextData(out data);

                return(data);
            });

            // QueryRepository is constructed by calling IQueryRepositoryBuilder.CreateQueryRepository
            container.RegisterCustomResolver(
                typeof(QueryRepository),
                t =>
            {
                var repositoryBuilder  = container.Resolve <IQueryRepositoryBuilder>();
                var workspace          = container.Resolve <ODataTestWorkspace>();
                var queryTypeLibrary   = container.Resolve <QueryTypeLibrary>();
                var entityContaineData = container.Resolve <EntityContainerData>();

                var queryRepository = repositoryBuilder.CreateQueryRepository(workspace.ConceptualModel, queryTypeLibrary, entityContaineData);

                return(queryRepository);
            });

            container.RegisterCustomResolver(
                typeof(IEntityModelConceptualDataServices),
                t =>
            {
                var workspace = container.Resolve <ODataTestWorkspace>();

                // Add data generation hints before creating structural data services
                ODataTaupoTestUtils.ResolveDataGenerationHints(workspace.ConceptualModel, container);

                var builder  = container.Resolve <IEntityModelConceptualDataServicesFactory>();
                var services = builder.CreateConceptualDataServices(workspace.ConceptualModel);
                ExceptionUtilities.CheckObjectNotNull(services, "Structural data services builder returned null unexpectedly");

                return(services);
            });

            container.RegisterCustomResolver(typeof(IAsyncDataSynchronizer), t => null);
        }
コード例 #18
0
        /// <summary>
        /// Examines the required relationships from <paramref name="source"/> and then populates them in <paramref name="graph"/>.
        /// </summary>
        /// <param name="graph">The <see cref="List{IEntitySetData}"/> to which to add the new instance.</param>
        /// <param name="source">The entity from which to find required relationships and populate them.</param>
        /// <param name="sourceEntitySet">The <see cref="EntitySet"/> in which <paramref name="source"/> resides.</param>
        /// <param name="sourceEntityType">The <see cref="EntityType"/> of which the <paramref name="source"/> is an instance.</param>
        /// <param name="sourceKey">The <see cref="EntityDataKey"/> of the <paramref name="source"/> instance.</param>
        /// <param name="data"><see cref="EntityContainerData"/> that contains the structural data from which to create objects.</param>
        /// <param name="processedEntities">The entity instances which have been translated from structural data into objects.</param>
        /// <param name="processedAssociations">The association instances which have been translated from structural data into calls to <paramref name="connectEntities"/>.</param>
        /// <param name="entityCreated">A callback function invoked every time a new entity instance is created and its properties are initialized.</param>
        /// <param name="connectEntities">A callback used to connect two objects together. Examples of actions include setting navigation properties,
        /// synchronizing FKs to PK values, and/or using the IRelatedEnd or SetLink APIs. The first two parameters are the objects that need to
        /// be connected, and the third is the <see cref="RelationshipSide"/> describing the side of the relationship which the first object participates
        /// in.</param>
        private void CreateGraphCore(
            List <IEntitySetData> graph,
            IEntitySetData source,
            EntitySet sourceEntitySet,
            EntityType sourceEntityType,
            EntityDataKey sourceKey,
            EntityContainerData data,
            Dictionary <EntityKey, IEntitySetData> processedEntities,
            HashSet <AssociationInstance> processedAssociations,
            Action <IEntitySetData> entityCreated,
            ConnectEntitiesCallback connectEntities)
        {
            var requiredRelationships =
                from r in sourceEntitySet.Container.RelationshipTypes()
                let side = r.Sides.FirstOrDefault(e =>
                                                  sourceEntityType.IsKindOf(e.FromEntityType) &&
                                                  sourceEntitySet == e.FromEntitySet &&
                                                  e.ToMultiplicity == EndMultiplicity.One)
                           where side != null
                           select new
            {
                Relationship = r,
                SourceSide   = side
            };

            foreach (var r in requiredRelationships)
            {
                var relationship   = r.Relationship;
                var sourceSide     = r.SourceSide;
                var associationRow = data.GetAssociationSetData(relationship.AssociationSet.Name).Rows
                                     .Single(row => row.GetRoleKey(sourceSide.FromRoleName).Equals(sourceKey));
                var targetKey       = associationRow.GetRoleKey(sourceSide.ToRoleName);
                var targetEntitySet = sourceSide.ToEntitySet;
                var targetEntityKey = new EntityKey(targetEntitySet.ContainerQualifiedName, targetKey);

                IEntitySetData targetEntity;
                if (!processedEntities.TryGetValue(targetEntityKey, out targetEntity))
                {
                    var targetRow = data.GetEntitySetData(targetEntitySet.Name).Rows.Single(row => row.Key.Equals(targetKey));
                    targetEntity = this.CreateObjectFromRow(targetRow);

                    if (entityCreated != null)
                    {
                        entityCreated(targetEntity);
                    }

                    graph.Add(targetEntity);
                    processedEntities.Add(targetEntityKey, targetEntity);
                    InvokeConnectEntitiesCallback(source, targetEntity, relationship, sourceSide, processedAssociations, connectEntities);

                    this.CreateGraphCore(
                        graph,
                        targetEntity,
                        targetEntitySet,
                        targetRow.EntityType,
                        targetKey,
                        data,
                        processedEntities,
                        processedAssociations,
                        entityCreated,
                        connectEntities);
                }
                else
                {
                    InvokeConnectEntitiesCallback(source, targetEntity, relationship, sourceSide, processedAssociations, connectEntities);
                }
            }
        }
コード例 #19
0
        /// <summary>
        /// Adds seed data to the <see cref="EntityContainerData"/> created by this instance by
        /// calling <see cref="TryPopulateNextData"/>.
        /// </summary>
        /// <param name="entitySet">The <see cref="EntitySet"/> to which the new seed instance belongs.</param>
        /// <param name="entityType">The <see cref="EntityType"/> of the new seed instance.</param>
        /// <param name="entityData">A collection of <see cref="NamedValue"/>s that describe the structural data of the instance.</param>
        /// <returns>The <see cref="EntityDataKey"/> that describes the seed instance.</returns>
        public EntityDataKey Seed(EntitySet entitySet, EntityType entityType, IEnumerable<NamedValue> entityData)
        {
            this.CreateEntitySetAndTypeSelectorIfNull();
            this.CreateRelationshipSelectorsIfNull();

            if (this.seedData == null)
            {
                this.seedData = new EntityContainerData(this.entityContainer);
            }

            var seedRow = this.PopulateEntitySetRow(this.seedData, entitySet, entityType, entityData);
            this.ConsiderCandidateForRelationships(seedRow);

            return seedRow.Key;
        }
コード例 #20
0
        /// <summary>
        /// Builds the <see cref="QueryDataSet"/> from the specified container data and query queryRepository.
        /// </summary>
        /// <param name="rootDataTypeMap">The collection of rootDataTypes used to build the data set.</param>
        /// <param name="entityContainerData">Entity Container Data</param>
        /// <returns>
        /// Instance of <see cref="QueryDataSet"/> with data populated from the containerData
        /// </returns>
        public virtual IQueryDataSet Build(IDictionary <string, QueryStructuralType> rootDataTypeMap, EntityContainerData entityContainerData)
        {
            QueryDataSet dataSet = new QueryDataSet();

            this.rootDataTypes = rootDataTypeMap;
            this.rowInstances  = new Dictionary <string, Dictionary <EntityDataKey, QueryStructuralValue> >();

            if (null != entityContainerData)
            {
                // phase 1 - build stub QueryStructuralValues for each EntityDataSetRow
                // and create result collections. We're doing it in two phases so that we
                // can set up relationships more easily since all objects
                // are guaranteed to exist.
                foreach (var entitySet in entityContainerData.EntityContainer.EntitySets)
                {
                    var entitySetData = entityContainerData.GetEntitySetData(entitySet.Name);
                    var collection    = this.BuildStubEntities(entitySetData);

                    dataSet.RootQueryData[entitySet.Name] = collection;
                }

                // phase 2 - copy actual data into pre-generated objects
                foreach (var entitySet in entityContainerData.EntityContainer.EntitySets)
                {
                    var entitySetData = entityContainerData.GetEntitySetData(entitySet.Name);

                    this.PopulateObjectInstances(entitySetData);
                }
            }

            return(dataSet);
        }
コード例 #21
0
 /// <summary>
 ///  Resolves referential constraint in the <see cref="EntityContainerData"/>.
 /// </summary>
 /// <param name="data">The entity container data where to resolve referential constraints.</param>
 public void ResolveReferentialConstraints(EntityContainerData data)
 {
     var resolver = new ConstraintsResolver(data);
     resolver.Resolve();
 }
コード例 #22
0
        private void ConvertEntityProperty(SerializableEntity entity, EntityContainerData data, Dictionary<SerializableEntity, EntitySetDataRow> rowMap)
        {
            var row = rowMap[entity];

            foreach (var prop in entity.Properties)
            {
                var relatedRows = prop.Value as IEnumerable<SerializableEntity>;
                var relatedRow = prop.Value as SerializableEntity;
                if (relatedRows == null)
                {
                    if (relatedRow != null)
                    {
                        relatedRows = new[] { relatedRow };
                    }
                }

                if (relatedRows != null)
                {
                    var type = row.EntityType;
                    var navprop = type.AllNavigationProperties.Single(c => c.Name == prop.Name);

                    // handle MEST scenario where there are multiple association sets corresponding to a navigation property
                    var assocSets = data.EntityContainer.AssociationSets.Where(c => c.AssociationType == navprop.Association);
                    var assocSet = assocSets.Single(set => set.Ends.Any(end => end.AssociationEnd == navprop.FromAssociationEnd && end.EntitySet.Name == entity.EntitySetName));

                    var associationSetData = data[assocSet];

                    foreach (var rr in relatedRows)
                    {
                        if (!associationSetData.Rows.Where(c => c.GetRoleKey(navprop.FromAssociationEnd.RoleName) == row.Key && c.GetRoleKey(navprop.ToAssociationEnd.RoleName) == rowMap[rr].Key).Any())
                        {
                            var associationRow = associationSetData.AddNewRow();
                            associationRow.SetRoleKey(navprop.FromAssociationEnd.RoleName, row.Key);
                            associationRow.SetRoleKey(navprop.ToAssociationEnd.RoleName, rowMap[rr].Key);
                        }
                    }
                }
                else
                {
                    // it could still be a null navigation property
                    var navigation = row.EntityType.AllNavigationProperties.SingleOrDefault(p => p.Name == prop.Name);
                    if (navigation == null)
                    {
                        var namedValue = this.Convert(prop);
                        row.SetValue(namedValue.Name, namedValue.Value);
                    }
                }
            }
        }
コード例 #23
0
        private void CreateRelationships(
            EntityContainerData data,
            ref int createdEntitiesCount,
            ref int createdAssociationsCount)
        {
            List<RelationshipDescription> relationshipsToCreate;
            List<KeyValuePair<EntitySet, EntityType>> entitiesToCreateInCurrentBatch;
            int loopCount = 0;
            while (this.GetRelationshipsAndEntitiesToCreate(out relationshipsToCreate, out entitiesToCreateInCurrentBatch))
            {
                loopCount++;

                // there are times when relationships are unable to be created for particular entity type graphs
                // in these situations this check guards against running infinitely long, adding 20
                // ensures that all models get at least 100 loops to generate relationship data, otherwise this 
                // guard might be too low
                if (loopCount > ((this.relationshipSelectors.Count * 4) + 20))
                {
                    throw new TaupoInvalidOperationException("Specified relationship requirements cannot be met. Make sure capacity selectors don't contradict each other.");
                }

                this.PopulateAssociationSetRows(data, relationshipsToCreate);
                createdAssociationsCount += relationshipsToCreate.Count;

                foreach (var setTypePair in entitiesToCreateInCurrentBatch)
                {
                    EntitySetDataRow r = this.PopulateNewEntitySetRow(data, setTypePair.Key, setTypePair.Value);
                    createdEntitiesCount++;
                    this.ConsiderCandidateForRelationships(r);
                }
            }
        }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssociationSetData"/> class.
 /// </summary>
 /// <param name="parent">The parent entity container data.</param>
 /// <param name="associationSet">The association set.</param>
 internal AssociationSetData(EntityContainerData parent, AssociationSet associationSet)
 {
     this.Parent = parent;
     this.AssociationSet = associationSet;
     this.Rows = new List<AssociationSetDataRow>();
 }
コード例 #25
0
        private EntitySetDataRow PopulateEntitySetRow(EntityContainerData data, EntitySet entitySet, EntityType entityType, IEnumerable<NamedValue> entityData)
        {
            EntitySetDataRow row = data[entitySet].AddNewRowOfType(entityType);

            foreach (NamedValue namedValue in entityData)
            {
                row.SetValue(namedValue.Name, namedValue.Value);
            }

            this.entitySetAndTypeSelector.IncrementCount(entitySet, entityType);

            return row;
        }
コード例 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConstraintsResolver"/> class.
 /// </summary>
 /// <param name="data">The entity container data to resolve referential constraints.</param>
 public ConstraintsResolver(EntityContainerData data)
 {
     this.data = data;
     this.Initialize();
 }
コード例 #27
0
        private EntitySetDataRow PopulateNewEntitySetRow(EntityContainerData data, EntitySet entitySet, EntityType entityType)
        {
            var entityData = this.StructuralDataServices.GetStructuralGenerator(entityType.FullName, this.EntityContainer.Name + "." + entitySet.Name).GenerateData();

            return(this.PopulateEntitySetRow(data, entitySet, entityType, entityData));
        }
コード例 #28
0
        /// <summary>
        /// Deserialize binary stream to this entity
        /// </summary>
        /// <param name="bytes">the binary to turn into an entity</param>
        /// <returns>the entity</returns>
        public override IEntity DeSerialize(byte[] bytes)
        {
            var entityBinaryConvert = new DataUtility.EntityFileData(bytes);
            var xDoc = entityBinaryConvert.XDoc;

            var newEntity = new Inanimate();

            var versionFormat = xDoc.Root.GetSafeAttributeValue <int>("formattingVersion");

            newEntity.BirthMark = xDoc.Root.GetSafeAttributeValue("Birthmark");
            newEntity.Birthdate = xDoc.Root.GetSafeAttributeValue <DateTime>("Birthdate");

            var internalCompositions = xDoc.Root.Element("BackingData").GetSafeAttributeValue("InternalComposition");
            var backingData          = new InanimateData(internalCompositions);

            backingData.ID          = xDoc.Root.Element("BackingData").GetSafeAttributeValue <long>("ID");
            backingData.Name        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Name");
            backingData.LastRevised = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("LastRevised");
            backingData.Created     = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("Created");

            foreach (var item in xDoc.Root.Element("BackingData").Element("InanimateContainers").Elements("Item"))
            {
                var newContainer = new EntityContainerData <IInanimate>();
                newContainer.CapacityVolume = item.GetSafeAttributeValue <long>("CapacityVolume");
                newContainer.CapacityWeight = item.GetSafeAttributeValue <long>("CapacityWeight");
                newContainer.Name           = item.GetSafeAttributeValue("Name");

                backingData.InanimateContainers.Add(newContainer);
            }

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("BackingData").Element("MobileContainers").Elements("Item"))
            {
                var newContainer = new EntityContainerData <IMobile>();
                newContainer.CapacityVolume = item.GetSafeAttributeValue <long>("CapacityVolume");
                newContainer.CapacityWeight = item.GetSafeAttributeValue <long>("CapacityWeight");
                newContainer.Name           = item.GetSafeAttributeValue("Name");

                backingData.MobileContainers.Add(newContainer);
            }

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("MobilesInside").Elements("Item"))
            {
                var obj = new Intelligence();
                obj.BirthMark = item.GetSafeAttributeValue("Birthmark");
                var containerName = item.GetSafeAttributeValue("Container");

                if (!String.IsNullOrWhiteSpace(containerName))
                {
                    newEntity.MobilesInside.Add(obj, containerName);
                }
                else
                {
                    newEntity.MobilesInside.Add(obj);
                }
            }


            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("Contents").Elements("Item"))
            {
                var obj = new Inanimate();
                obj.BirthMark = item.GetSafeAttributeValue("Birthmark");
                var containerName = item.GetSafeAttributeValue("Container");

                if (!String.IsNullOrWhiteSpace(containerName))
                {
                    newEntity.Contents.Add(obj, containerName);
                }
                else
                {
                    newEntity.Contents.Add(obj);
                }
            }

            //Add new version transformations here, they are meant to be iterative, hence < 1
            Transform_V1(backingData, newEntity, xDoc.Root, versionFormat < 1);

            newEntity.DataTemplate = backingData;

            //keywords is last
            newEntity.Keywords = xDoc.Root.Element("LiveData").Attribute("Keywords").Value.Split(new char[] { ',' });

            return(newEntity);
        }
コード例 #29
0
 /// <summary>
 /// Factory method that creates a new instance of the QueryRepository.
 /// </summary>
 /// <param name="entityModelSchema">Entity Model Schema</param>
 /// <param name="queryTypeLibrary">Query Type Library</param>
 /// <param name="entityContainerData">Entity Container Data</param>
 /// <returns>An instance of the QueryRepository class.</returns>
 public override QueryRepository CreateQueryRepository(EntityModelSchema entityModelSchema, QueryTypeLibrary queryTypeLibrary, EntityContainerData entityContainerData)
 {
     return(this.CreateRepositoryFunc(entityModelSchema, queryTypeLibrary, entityContainerData));
 }
コード例 #30
0
        /// <summary>
        /// Factory method that creates a new instance of the QueryRepository.
        /// </summary>
        /// <param name="entityModelSchema">Entity Model Schema</param>
        /// <param name="queryTypeLibrary">Query Type Library</param>
        /// <param name="entityContainerData">Entity Container Data</param>
        /// <returns>An instance of the QueryRepository class.</returns>
        public virtual QueryRepository CreateQueryRepository(EntityModelSchema entityModelSchema, QueryTypeLibrary queryTypeLibrary, EntityContainerData entityContainerData)
        {
            this.RootDataTypes = new Dictionary <string, QueryStructuralType>();

            this.BuildPrimitiveTypes(queryTypeLibrary);
            this.BuildRootQueriesAndTypes(entityModelSchema, queryTypeLibrary);

            var dataSet = this.DataSetBuilder.Build(this.RootDataTypes, entityContainerData);

            this.BuildConstants(queryTypeLibrary, dataSet);

            QueryRepository repository = new QueryRepository(queryTypeLibrary, this.RootQueries, this.Constants, this.PrimitiveTypes, this.RootDataTypes, dataSet);

            return(repository);
        }
コード例 #31
0
ファイル: InanimateData.cs プロジェクト: carriercomm/NetMud
        /// <summary>
        /// Fills a data object with data from a data row
        /// </summary>
        /// <param name="dr">the data row to fill from</param>
        public override void Fill(DataRow dr)
        {
            ID = DataUtility.GetFromDataRow<long>(dr, "ID");
            Created = DataUtility.GetFromDataRow<DateTime>(dr, "Created");
            LastRevised = DataUtility.GetFromDataRow<DateTime>(dr, "LastRevised");
            Name = DataUtility.GetFromDataRow<string>(dr, "Name");

            string mobileContainerJson = DataUtility.GetFromDataRow<string>(dr, "MobileContainers");

            dynamic mobileContainers = JsonConvert.DeserializeObject(mobileContainerJson);
            foreach(dynamic mobileContainer in mobileContainers)
            {
                var newContainer = new EntityContainerData<IMobile>();
                newContainer.CapacityVolume = mobileContainer.CapacityVolume;
                newContainer.CapacityWeight = mobileContainer.CapacityWeight;
                newContainer.Name = mobileContainer.Name;

                MobileContainers.Add(newContainer);
            }

            string inanimateContainerJson = DataUtility.GetFromDataRow<string>(dr, "InanimateContainers");

            dynamic inanimateContainers = JsonConvert.DeserializeObject(inanimateContainerJson);
            foreach (dynamic inanimateContainer in inanimateContainers)
            {
                var newContainer = new EntityContainerData<IInanimate>();
                newContainer.CapacityVolume = inanimateContainer.CapacityVolume;
                newContainer.CapacityWeight = inanimateContainer.CapacityWeight;
                newContainer.Name = inanimateContainer.Name;

                InanimateContainers.Add(newContainer);
            }

            string internalCompositionJson = DataUtility.GetFromDataRow<string>(dr, "InternalComposition");
            InternalComposition = DeserializeInternalCompositions(internalCompositionJson);

            Model = new DimensionalModel(dr);
        }
コード例 #32
0
        /// <summary>
        /// Tries to get next data to upload.
        /// </summary>
        /// <param name="data">The data to upload.</param>
        /// <returns>True if there is a data for upload, false otherwise.</returns>
        public virtual bool TryPopulateNextData(out EntityContainerData data)
        {
            ExceptionUtilities.CheckObjectNotNull(this.StructuralDataServices, "StructuralGenerators cannot be null.");

            this.CreateEntitySetAndTypeSelectorIfNull();
            this.CreateRelationshipSelectorsIfNull();

            if (this.seedData != null)
            {
                data = this.seedData;
                this.seedData = null;
            }
            else
            {
                data = new EntityContainerData(this.EntityContainer);
            }

            int createdEntitiesCount = 0, createdAssociationsCount = 0;
            this.CreateRelationships(data, ref createdEntitiesCount, ref createdAssociationsCount);

            EntitySet entitySet;
            EntityType entityType;
            while (this.GetNextEntitySetAndTypeToCreate(out entitySet, out entityType))
            {
                EntitySetDataRow row = this.PopulateNewEntitySetRow(data, entitySet, entityType);
                createdEntitiesCount++;
                this.ConsiderCandidateForRelationships(row);

                this.CreateRelationships(data, ref createdEntitiesCount, ref createdAssociationsCount);

                if (createdEntitiesCount >= this.ThresholdForNumberOfEntities && this.ThresholdForNumberOfEntities != -1)
                {
                    break;
                }
            }

            if (this.ReferentialConstraintsResolver != null)
            {
                this.ReferentialConstraintsResolver.ResolveReferentialConstraints(data);
            }

            return createdEntitiesCount > 0 || createdAssociationsCount > 0;
        }
コード例 #33
0
 /// <summary>
 /// Builds the <see cref="QueryDataSet"/> from the specified container data and query queryRepository.
 /// </summary>
 /// <param name="rootDataTypeMap">The collection of rootDataTypes used to build the data set.</param>
 /// <param name="entityContainerData">Entity Container Data that contains the information to be used in the QueryDataSet</param>
 /// <returns>
 /// Instance of <see cref="QueryDataSet"/> with data populated from the containerData
 /// </returns>
 public override IQueryDataSet Build(IDictionary<string, QueryStructuralType> rootDataTypeMap, EntityContainerData entityContainerData)
 {
     return this.BuildQueryDataSetFunc(rootDataTypeMap, entityContainerData);
 }
コード例 #34
0
        private EntitySetDataRow PopulateNewEntitySetRow(EntityContainerData data, EntitySet entitySet, EntityType entityType)
        {
            var entityData = this.StructuralDataServices.GetStructuralGenerator(entityType.FullName, this.EntityContainer.Name + "." + entitySet.Name).GenerateData();

            return this.PopulateEntitySetRow(data, entitySet, entityType, entityData);
        }
コード例 #35
0
        /// <summary>
        ///  Resolves referential constraint in the <see cref="EntityContainerData"/>.
        /// </summary>
        /// <param name="data">The entity container data where to resolve referential constraints.</param>
        public void ResolveReferentialConstraints(EntityContainerData data)
        {
            var resolver = new ConstraintsResolver(data);

            resolver.Resolve();
        }
コード例 #36
0
 private void PopulateAssociationSetRows(EntityContainerData data, IEnumerable<RelationshipDescription> relationshipsToCreate)
 {
     foreach (RelationshipDescription rd in relationshipsToCreate)
     {
         AssociationSetDataRow row = data[rd.AssociationSet].AddNewRow();
         row.SetRoleKey(rd.ToRoleName, rd.To);
         row.SetRoleKey(rd.FromRoleName, rd.From);
     }
 }
コード例 #37
0
        /// <summary>
        /// The configuration of these dependencies will be called from other testcase hierarchies that do not inherit from this class.
        /// This method can be used in such hierarchies.
        /// </summary>
        /// <param name="container">container on which to register impelemntation dependencies</param>
        public static void ConfigureDependenciesHelper(DependencyInjectionContainer container)
        {
            container.Register<IClrTypeReferenceResolver, StronglyTypedClrTypeReferenceResolver>();
            container.Register<IObjectLayerCodeGenerator, StronglyTypedObjectLayerCodeGenerator>();
            container.Register<IQueryEvaluationStrategy, ClrQueryEvaluationStrategy>();
            container.Register<IModelGenerator, ODataV2ModelGenerator>();
            container.Register<IWorkspaceBuilder, ODataWorkspaceBuilder>(); // Is this also needed , since we register Custom Resolver below
            container.Register<IQueryRepositoryBuilder, AstoriaQueryRepositoryBuilderBase>();
            container.Register<IQueryDataSetBuilder, ODataQueryDataSetBuilder>();

            container.Register<IResourceLookup, AssemblyResourceLookup>();
            container.Register<IStringResourceVerifier, StringResourceVerifier>();
            container.Register<IQueryScalarValueToClrValueComparer, QueryScalarValueToClrValueComparer>();
            container.Register<IQueryExpressionEvaluator, LinqToAstoriaEvaluator>();
            container.Register<IClientCodeLayerGenerator, PocoClientCodeLayerGenerator>();

            container.Register<ILinqToAstoriaQueryEvaluationStrategy, LinqToAstoriaClrQueryEvaluationStrategy>();
            container.Register<IPrimitiveDataTypeResolver, NullPrimitiveDataTypeResolver>();
            container.Register<ILinqResultComparerContextAdapter, ODataObjectResultComparerContextAdapter>();

            container.Register<ISpatialClrTypeResolver, SpatialClrTypeResolver>();
            container.Register<ISpatialDataTypeDefinitionResolver, SpatialDataTypeDefinitionResolver>();
            container.Register<IPayloadTransformFactory, ODataLibPayloadTransformFactory>();

            container.RegisterCustomResolver(
                typeof(ODataTestWorkspace),
                t =>
                {
                    var builder = container.Resolve<ODataWorkspaceBuilder>();
                    var modelGenerator = container.Resolve<IModelGenerator>();
                    var workspace = builder.BuildWorkspace(modelGenerator.GenerateModel());
                    
                    return workspace;
                });

            container.RegisterCustomResolver(
                typeof(IQueryTypeLibraryBuilder),
                queryTypeLibBuilderResolver =>
                {
                    var queryEvaluationStrategy = container.Resolve<ILinqToAstoriaQueryEvaluationStrategy>();
                    var primitiveTypeResolver = container.Resolve<IPrimitiveDataTypeResolver>();
                    return new AstoriaQueryTypeLibraryBuilder(queryEvaluationStrategy, primitiveTypeResolver, new EdmDataTypeResolver());
                });

            // IQueryDataSet is built by the repository builder
            container.RegisterCustomResolver(
                typeof(IQueryDataSet),
                    t =>
                    {
                        var repository = container.Resolve<QueryRepository>();
                        return repository.DataSet;
                    });

            container.RegisterCustomResolver(
                typeof(QueryTypeLibrary),
                queryTypeLib =>
                {
                    var workspace = container.Resolve<ODataTestWorkspace>();
                    var queryTypeLibraryBuilder = container.Resolve<IQueryTypeLibraryBuilder>();
                    var queryTypeLibrary = queryTypeLibraryBuilder.BuildLibraryWithoutClrTypeMapping(workspace.ConceptualModel);
                    if (workspace.ObjectLayerAssembly != null)
                    {
                        queryTypeLibrary.UpdateClrTypeMapping(new[] { workspace.ObjectLayerAssembly });
                    }

                    return queryTypeLibrary;
                });

            container.RegisterCustomResolver(
                typeof(EntityContainerData),
                t =>
                {
                    // TODO: All Query tests fail when there is actual data, for now starting with empty data
                    var workspace = container.Resolve<ODataTestWorkspace>();
                    EntityContainerData data = null;
                    data = new EntityContainerData(workspace.ConceptualModel.GetDefaultEntityContainer());
                    
                    //var dataPopulationDriver = container.Resolve<EntityContainerDataPopulationDriver>();
                    //dataPopulationDriver.ThresholdForNumberOfEntities = -1;
                    //dataPopulationDriver.EntityContainer = workspace.ConceptualModel.GetDefaultEntityContainer();
                    //dataPopulationDriver.TryPopulateNextData(out data);
                    
                    return data;
                });

            // QueryRepository is constructed by calling IQueryRepositoryBuilder.CreateQueryRepository
            container.RegisterCustomResolver(
                typeof(QueryRepository),
                t =>
                {
                    var repositoryBuilder = container.Resolve<IQueryRepositoryBuilder>();
                    var workspace = container.Resolve<ODataTestWorkspace>();
                    var queryTypeLibrary = container.Resolve<QueryTypeLibrary>();
                    var entityContaineData = container.Resolve<EntityContainerData>();

                    var queryRepository = repositoryBuilder.CreateQueryRepository(workspace.ConceptualModel, queryTypeLibrary, entityContaineData);
                    
                    return queryRepository;
                });

            container.RegisterCustomResolver(
                typeof(IEntityModelConceptualDataServices),
                t =>
                {
                    var workspace = container.Resolve<ODataTestWorkspace>();

                    // Add data generation hints before creating structural data services
                    ODataTaupoTestUtils.ResolveDataGenerationHints(workspace.ConceptualModel, container);

                    var builder = container.Resolve<IEntityModelConceptualDataServicesFactory>();
                    var services = builder.CreateConceptualDataServices(workspace.ConceptualModel);
                    ExceptionUtilities.CheckObjectNotNull(services, "Structural data services builder returned null unexpectedly");

                    return services;
                });

            container.RegisterCustomResolver(typeof(IAsyncDataSynchronizer), t => null);
        }