Esempio n. 1
0
        public void SetUp()
        {
            try
            {
                _sqlExecutor       = SetupSqlQueryExecutor();
                _crudFactory       = CrudFactory.GetFactory(_sqlExecutor);
                _clientDataLoader  = _crudFactory.ClientLoader;
                _clientDataSaver   = _crudFactory.ClientSaver;
                _clientDataDeleter = _crudFactory.ClientDeleter;

                Assert.NotNull(_sqlExecutor);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Esempio n. 2
0
 public void SetUp()
 {
     _dataServices = null;
     try
     {
         _sqlExecutor       = SetupSqlQueryExecutor();
         _crudFactory       = CrudFactory.GetFactory(_sqlExecutor);
         _dataServices      = new DataServiceImplementation(_sqlExecutor);
         _officeDataLoader  = _crudFactory.GetOfficeLoader();
         _officeDataSaver   = _crudFactory.GetOfficeSaver();
         _officeDataDeleter = _crudFactory.GetOfficeDeleter();
         Assert.NotNull(_sqlExecutor);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Esempio n. 3
0
        private void Initialize()
        {
            // Get Schema
            _schema = TableSchema <TValue> .GetSchema();

            if (_schema.Keys.Count != 1)
            {
                throw new ArgumentException("The specified type does not have a valid Schema.  The KeyList class requires a single-part key");
            }

            // Get LoadNew Method
            _loadNewMethod = (typeof(TValue)).GetMethod("LoadNew", BindingFlags.NonPublic | BindingFlags.Static);
            if (_loadNewMethod == null)
            {
                throw new ArgumentException("The specified type does not have a compatible static LoadNew method.");
            }

            // Get database name of key column
            foreach (var col in _schema.Keys)
            {
                _keyColumn = col.Value;
                break;
            }

            // Check for SelectCommand in type, if it is there use it!
            System.Reflection.FieldInfo fi = (typeof(TValue)).GetField("SelectCommand", BindingFlags.NonPublic | BindingFlags.Static);
            if (fi != null)
            {
                _selectValuesTemplate  = (string)fi.GetValue(null);
                _selectKeyListTemplate = CrudFactory.MakeSelectKeyTemplate(_schema, _selectValuesTemplate);
            }
            else
            {
                _selectValuesTemplate  = CrudFactory.MakeSelectTemplate(_schema);
                _selectKeyListTemplate = CrudFactory.MakeSelectKeyTemplate(_schema);
            }

            // Get select templates
            _selectOneCommand = CreateSelectOneCommand();
            _selectOneCommand.Prepare();
            _selectBlockCommand = CreateSelectBlockCommand();
            _selectBlockCommand.Prepare();
        }