public void Delete(IEnumerable <DataSourceId> dataSourceIds, DataProviderContext dataProivderContext) { DataContext dataContext = null; try { foreach (DataSourceId dataSourceId in dataSourceIds) { if (dataSourceId == null) { throw new ArgumentException("dataSourceIds contains nulls"); } using (new DataScope(dataSourceId.DataScopeIdentifier, dataSourceId.LocaleScope)) { SqlDataTypeStore sqlDataTypeStore = TryGetsqlDataTypeStore(dataSourceId.InterfaceType); if (sqlDataTypeStore == null) { throw new InvalidOperationException(string.Format("The interface '{0}' has not been configures", dataSourceId.InterfaceType.FullName)); } IData data = sqlDataTypeStore.GetDataByDataId(dataSourceId.DataId, dataProivderContext); Verify.That(data != null, "Row has already been deleted"); if (dataContext == null) { dataContext = CreateDataContext(); } sqlDataTypeStore.RemoveData(data, dataContext); } } if (dataContext != null) { SubmitChanges(dataContext); } } finally { if (dataContext != null) { dataContext.Dispose(); } } }
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); } }