public void LoadRelationship()
        {
            var database = TestConfiguration.GetDatabase();

            var relatedEntity = new StringIdModel
            {
                Description = "LoadRelationship-RelatedItem"
            };
            var dbEntityWriter = new DbEntityWriter <StringIdModel>(database);
            var collection     = new DbEntityCollection <StringIdModel>
            {
                relatedEntity
            };

            dbEntityWriter.Write(collection);

            var entity = new SingleEntityIntegrationModel
            {
                RelatedItemId = relatedEntity.Id
            };

            var entityMapper = new EntityMapper <SingleEntityIntegrationModel>();

            new NavigationPropertyMutator <SingleEntityIntegrationModel>().MutateEntity(entity, MutatorType.Select, entityMapper, database);

            Assert.AreEqual("LoadRelationship-RelatedItem", entity.RelatedItem.Description);
        }
        public void LoadRelationship()
        {
            var connection = TestConfiguration.GetConnection();

            var relatedEntity = new StringIdModel
            {
                Description = "LoadRelationship-RelatedItem"
            };
            var writerPipeline   = new EntityWriterPipeline <StringIdModel>(connection);
            var entityCollection = new EntityCollection <StringIdModel>()
            {
                relatedEntity
            };

            writerPipeline.AddCollection(entityCollection);
            writerPipeline.Write();

            var entity = new SingleEntityIntegrationModel
            {
                RelatedItemId = relatedEntity.Id
            };

            new NavigationPropertyMutator <SingleEntityIntegrationModel>().MutateEntity(entity, MutatorType.Select, connection);

            Assert.AreEqual("LoadRelationship-RelatedItem", entity.RelatedItem.Description);
        }
        public async Task AddRelationshipToNewEntityAsync()
        {
            var connection = TestConfiguration.GetConnection();
            var entity     = new SingleEntityIntegrationModel
            {
                RelatedItem = new StringIdModel
                {
                    Description = "SaveNewEntity-RelatedItem"
                }
            };

            var entityRelationshipWriter = new EntityRelationshipWriter <SingleEntityIntegrationModel>(connection);

            await entityRelationshipWriter.CommitEntityRelationshipsAsync(new[] { entity }).ConfigureAwait(false);

            Assert.IsNotNull(entity.RelatedItemId);
            Assert.IsTrue(entity.RelatedItemId == entity.RelatedItem.Id);
        }
        public void AddRelationshipToNewEntity()
        {
            var database = TestConfiguration.GetDatabase();
            var entity   = new SingleEntityIntegrationModel
            {
                RelatedItem = new StringIdModel
                {
                    Description = "SaveNewEntity-RelatedItem"
                }
            };

            var entityMapper             = new EntityMapper <SingleEntityIntegrationModel>();
            var entityRelationshipWriter = new EntityRelationshipWriter <SingleEntityIntegrationModel>(database, entityMapper);

            entityRelationshipWriter.CommitEntityRelationships(new[] { entity });

            Assert.IsNotNull(entity.RelatedItemId);
            Assert.IsTrue(entity.RelatedItemId == entity.RelatedItem.Id);
        }