The "context" for the DSP data provider. The context holds the actual data to be reported through the provider.
This implementation stores the data in a List and all of it is in-memory.
        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;
        }
예제 #2
0
 public MongoDSPUpdateProvider(string connectionString, DSPContext dataContext, MongoMetadata mongoMetadata)
     : base(dataContext, mongoMetadata.CreateDSPMetadata())
 {
     this.connectionString = connectionString;
     this.mongoMetadata = mongoMetadata;
 }
예제 #3
0
 /// <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>();
 }
예제 #4
0
 /// <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>();
 }
예제 #5
0
 /// <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>();
 }