GetResourceSetEntities() public method

Gets a list of resources for the specified resource set.
public GetResourceSetEntities ( string resourceSetName ) : IList
resourceSetName string The name of the resource set to get resources for.
return IList
コード例 #1
0
        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;
        }