Ejemplo n.º 1
0
        private static T BindDataSets <T>(
            T dataContext, DataContextCreationOptions dataContextCreationOptions,
            DataSchema schema, IQueryProvider queryProvider
            ) where T : DataContext
        {
            var metadata = _metadata.GetOrCreate(typeof(T), typeof(T)) as DataContextMetadata <T> ??
                           throw new Exception("Metadata cache corrupted.");

            foreach (var sqlProperty in metadata.SqlDataSets)
            {
                sqlProperty.CreateAndAssignDataSet(
                    dataContext, queryProvider, schema,
                    dataContextCreationOptions);
            }

            return(dataContext);
        }
Ejemplo n.º 2
0
        public static T Create <T>(IDataProvider dataProvider, DataContextCreationOptions dataContextCreationOptions = null)
            where T : DataContext, new()
        {
            if (dataProvider == null)
            {
                throw new ArgumentNullException(nameof(dataProvider));
            }

            var dataProviderProxy = new TransactingDataProviderProxy(dataProvider);

            if (dataContextCreationOptions == null)
            {
                dataContextCreationOptions = DataContextCreationOptions.Default;
            }

            var dataContextType = typeof(T);
            var schema          = _schemas.GetOrCreate(dataContextType, dataContextType);

            return(BindDataSets(new T
            {
                DataSchema = schema,
                _dataProvider = dataProviderProxy
            }, dataContextCreationOptions, schema, dataProviderProxy));
        }
Ejemplo n.º 3
0
 public void CreateAndAssignDataSet(TDataContext dataContext, IQueryProvider queryProvider,
                                    DataSchema dataSchema, DataContextCreationOptions dataContextCreationOptions)
 => _createAndAssignDataSet(dataContext, queryProvider,
                            dataSchema, dataContextCreationOptions);