Exemplo n.º 1
0
 /// <summary>
 /// Cleans and Dispose query cache manager
 /// </summary>
 internal void CleanupQueryCache()
 {
     if (null != _queryCacheManager)
     {
         _queryCacheManager.Dispose();
         _queryCacheManager = null;
     }
 }
Exemplo n.º 2
0
            internal void LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader)
            {
                StoreItemCollection     storeItemCollection = null;
                IEnumerable <XmlReader> sSpaceXmlReaders    = loader.CreateReaders(DataSpace.SSpace);

                try
                {
                    // Load the store side, however, only do so if we don't already have one
                    storeItemCollection = new StoreItemCollection(
                        sSpaceXmlReaders,
                        loader.GetPaths(DataSpace.SSpace));
                }
                finally
                {
                    Helper.DisposeXmlReaders(sSpaceXmlReaders);
                }

                // If this entry is getting re-used, make sure that the previous query cache manager gets
                // cleared up
                if (_queryCacheManager != null)
                {
                    _queryCacheManager.Clear();
                }

                // Update the query cache manager reference
                _queryCacheManager = storeItemCollection.QueryCacheManager;

                // With the store metadata in place, we can then load the mappings, however, only use it
                // if we don't already have one
                //
                StorageMappingItemCollection storageMappingItemCollection = null;
                IEnumerable <XmlReader>      csSpaceXmlReaders            = loader.CreateReaders(DataSpace.CSSpace);

                try
                {
                    storageMappingItemCollection = new StorageMappingItemCollection(
                        edmItemCollection,
                        storeItemCollection,
                        csSpaceXmlReaders,
                        loader.GetPaths(DataSpace.CSSpace));
                }
                finally
                {
                    Helper.DisposeXmlReaders(csSpaceXmlReaders);
                }

                List <string> permissionPaths = new List <string>();

                loader.CollectFilePermissionPaths(permissionPaths, DataSpace.SSpace);
                loader.CollectFilePermissionPaths(permissionPaths, DataSpace.CSSpace);
                FileIOPermission filePermissions = null;

                if (permissionPaths.Count > 0)
                {
                    filePermissions = new FileIOPermission(FileIOPermissionAccess.Read, permissionPaths.ToArray());
                }
                this.UpdateMetadataEntry(storageMappingItemCollection, filePermissions);
            }
        private static KeyValuePair <Shaper <RecordState>, CoordinatorFactory <RecordState> > CreateShaperInfo(DbDataReader storeDataReader, ColumnMap columnMap, MetadataWorkspace workspace)
        {
            Debug.Assert(storeDataReader != null, "null storeDataReaders?");
            Debug.Assert(columnMap != null, "null columnMap?");
            Debug.Assert(workspace != null, "null workspace?");

            System.Data.Common.QueryCache.QueryCacheManager cacheManager = workspace.GetQueryCacheManager();
            const System.Data.Objects.MergeOption           NoTracking   = System.Data.Objects.MergeOption.NoTracking;

            ShaperFactory <RecordState> shaperFactory = Translator.TranslateColumnMap <RecordState>(cacheManager, columnMap, workspace, null, NoTracking, true);
            Shaper <RecordState>        recordShaper  = shaperFactory.Create(storeDataReader, null, workspace, System.Data.Objects.MergeOption.NoTracking, true);

            return(new KeyValuePair <Shaper <RecordState>, CoordinatorFactory <RecordState> >(recordShaper, recordShaper.RootCoordinator.TypedCoordinatorFactory));
        }