Exemple #1
0
        public void Delete(IEnumerable <DataSourceId> dataSourceIds)
        {
            Verify.ArgumentNotNull(dataSourceIds, "dataSourceIds");

            using (TimerProfilerFacade.CreateTimerProfiler())
            {
                Type interfaceType = null;
                foreach (DataSourceId dataSourceId in dataSourceIds)
                {
                    if (dataSourceId == null)
                    {
                        throw new ArgumentException("datas enumeration may not contain nulls");
                    }

                    if (interfaceType == null)
                    {
                        interfaceType = dataSourceId.InterfaceType;
                    }
                    else if (interfaceType != dataSourceId.InterfaceType)
                    {
                        throw new ArgumentException(string.Format("Only one data interface per enumerable type supported"));
                    }
                }

                string errorMessage;
                if (!DataTypeValidationRegistry.IsValidForProvider(interfaceType, _dataProviderContext.ProviderName, out errorMessage))
                {
                    throw new InvalidOperationException(errorMessage);
                }

                _sqlDataTypeStoresContainer.Delete(dataSourceIds, _dataProviderContext);
            }
        }
Exemple #2
0
        public IQueryable <T> GetData <T>()
            where T : class, IData
        {
            using (TimerProfilerFacade.CreateTimerProfiler(typeof(T).ToString()))
            {
                string errorMessage;
                if (!DataTypeValidationRegistry.IsValidForProvider(typeof(T), _dataProviderContext.ProviderName, out errorMessage))
                {
                    throw new InvalidOperationException(errorMessage);
                }

                SqlDataTypeStore result = _sqlDataTypeStoresContainer.GetDataTypeStore(typeof(T));

                return((IQueryable <T>)result.GetQueryable());
            }
        }
Exemple #3
0
        public void AlterStore(UpdateDataTypeDescriptor updateDataTypeDescriptor, bool forceCompile)
        {
            var dataTypeChangeDescriptor = updateDataTypeDescriptor.CreateDataTypeChangeDescriptor();

            using (TimerProfilerFacade.CreateTimerProfiler())
            {
                SqlStoreManipulator.AlterStoresForType(updateDataTypeDescriptor);

                bool localizationChanged = dataTypeChangeDescriptor.AlteredType.Localizeable !=
                                           dataTypeChangeDescriptor.OriginalType.Localizeable;

                var oldElement = _interfaceConfigurationElements.Single(f => f.DataTypeId == updateDataTypeDescriptor.OldDataTypeDescriptor.DataTypeId);

                var newElement = InterfaceConfigurationManipulator.Change(_dataProviderContext.ProviderName, dataTypeChangeDescriptor, localizationChanged);
                if (newElement != null)
                {
                    _interfaceConfigurationElements.Remove(oldElement);
                    _interfaceConfigurationElements.Add(newElement);
                }

                if (forceCompile)
                {
                    Dictionary <DataTypeDescriptor, IEnumerable <SqlDataTypeStoreDataScope> > allSqlDataTypeStoreDataScopes = BuildAllExistingDataTypeStoreDataScopes();

                    InitializeStoreResult initializeStoreResult = InitializeStore(newElement ?? oldElement, allSqlDataTypeStoreDataScopes, true);

                    if (!updateDataTypeDescriptor.NewDataTypeDescriptor.IsCodeGenerated)
                    {
                        var interfaceType = updateDataTypeDescriptor.NewDataTypeDescriptor.GetInterfaceType();

                        if (!DataTypeValidationRegistry.IsValidForProvider(interfaceType, _dataProviderContext.ProviderName))
                        {
                            // Revalidating alternated static data type
                            _sqlDataTypeStoresContainer.RemoveKnownInterface(interfaceType);

                            DataTypeValidationRegistry.ClearValidationError(interfaceType, _dataProviderContext.ProviderName);

                            AddDataTypeStore(initializeStoreResult);
                        }
                    }
                }
            }
        }
Exemple #4
0
        public T GetData <T>(IDataId dataId)
            where T : class, IData
        {
            Verify.ArgumentNotNull(dataId, "dataId");

            using (TimerProfilerFacade.CreateTimerProfiler(string.Format("dataId ({0})", typeof(T))))
            {
                string errorMessage;
                if (!DataTypeValidationRegistry.IsValidForProvider(typeof(T), _dataProviderContext.ProviderName, out errorMessage))
                {
                    throw new InvalidOperationException(errorMessage);
                }

                SqlDataTypeStore result = _sqlDataTypeStoresContainer.GetDataTypeStore(typeof(T));

                IData data = result.GetDataByDataId(dataId, _dataProviderContext);

                return((T)data);
            }
        }
Exemple #5
0
        public List <T> AddNew <T>(IEnumerable <T> dataset)
            where T : class, IData
        {
            Verify.ArgumentNotNull(dataset, "dataset");

            using (TimerProfilerFacade.CreateTimerProfiler())
            {
                string errorMessage;
                if (!DataTypeValidationRegistry.IsValidForProvider(typeof(T), _dataProviderContext.ProviderName, out errorMessage))
                {
                    throw new InvalidOperationException(errorMessage);
                }

                using (var scope = new RequireTransactionScope())
                {
                    var result = _sqlDataTypeStoresContainer.AddNew <T>(dataset, _dataProviderContext);

                    scope.Complete();

                    return(result);
                }
            }
        }