public DSPContext CreateContext(DSPMetadata metadata) { if (cachedContext == null) { lock (this) { var dspContext = new DSPContext(); using (MongoContext mongoContext = new MongoContext(ConfigurationManager.ConnectionStrings["NorthwindContext.MongoDB"].ConnectionString)) { foreach (var resourceSet in metadata.ResourceSets) { var entities = dspContext.GetResourceSetEntities(resourceSet.Name); foreach (var bsonDocument in mongoContext.Database.GetCollection(resourceSet.Name).FindAll()) { var resource = CreateDSPResource(resourceSet.ResourceType, bsonDocument); entities.Add(resource); } } } foreach (var reference in resourceReferences) { resourceMap[reference.Item1].SetValue(reference.Item2, resourceMap[reference.Item3]); } foreach (var reference in resourceSetReferences) { var referencedCollection = new List<DSPResource>(); resourceMap[reference.Item1].SetValue(reference.Item2, referencedCollection); foreach (var objectId in reference.Item3) { referencedCollection.Add(resourceMap[objectId]); } } cachedContext = dspContext; } } return cachedContext; }
public MongoDSPUpdateProvider(string connectionString, DSPContext dataContext, MongoMetadata mongoMetadata) : base(dataContext, mongoMetadata.CreateDSPMetadata()) { this.connectionString = connectionString; this.mongoMetadata = mongoMetadata; }
/// <summary>Constructor.</summary> /// <param name="dataContext">The data context to apply the changes to.</param> /// <param name="metadata">The metadata describing the types to work with.</param> public DSPUpdateProvider(DSPContext dataContext, DSPMetadata metadata) { this.dataContext = dataContext; this.metadata = metadata; this.pendingChanges = new List <Action>(); }
/// <summary>Constructor.</summary> /// <param name="dataContext">The data context to apply the changes to.</param> /// <param name="metadata">The metadata describing the types to work with.</param> public DSPUpdateProvider(DSPContext dataContext, DSPMetadata metadata) { this.dataContext = dataContext; this.metadata = metadata; this.pendingChanges = new List<Action>(); }
/// <summary>Constructor.</summary> /// <param name="dataContext">The data context to apply the changes to.</param> /// <param name="metadata">The metadata describing the types to work with.</param> public DSPUpdateProvider(DSPContext dataContext, DSPMetadata metadata) { _dataContext = dataContext; _metadata = metadata; _pendingChanges = new List<Action>(); }