public IQueryable <T> GetData <T>() where T : class, IData { CheckTransactionNotInAbortedState(); XmlDataTypeStore dataTypeStore = _xmlDataTypeStoresContainer.GetDataTypeStore(typeof(T)); var currentDataScope = DataScopeManager.MapByType(typeof(T)); if (!dataTypeStore.HasDataScopeName(currentDataScope)) { return(Enumerable.Empty <T>().AsQueryable()); } var dataTypeStoreScope = dataTypeStore.GetDataScopeForType(typeof(T)); var fileRecord = XmlDataProviderDocumentCache.GetFileRecord( dataTypeStoreScope.Filename, dataTypeStoreScope.ElementName, dataTypeStore.Helper.CreateDataId); if (fileRecord.CachedTable == null) { ICollection <XElement> elements = fileRecord.ReadOnlyElementsList; Func <XElement, T> fun = dataTypeStore.Helper.CreateSelectFunction <T>(_dataProviderContext.ProviderName); var list = new List <T>(elements.Count); list.AddRange(elements.Select(fun)); fileRecord.CachedTable = new CachedTable <T>(list); } return(new CachingQueryable <T>(fileRecord.CachedTable, () => fileRecord.CachedTable.Queryable)); }
private static FileRecord GetFileRecord(XmlDataTypeStore dataTypeStore, XmlDataTypeStoreDataScope dataTypeStoreDataScope) { return(XmlDataProviderDocumentCache.GetFileRecord(dataTypeStoreDataScope.Filename, dataTypeStoreDataScope.ElementName, dataTypeStore.Helper.CreateDataId)); }