Beispiel #1
0
        public override Adapter GetAdapter()
        {
            var adapter = _wrappedStrategy.GetAdapter();

            adapter.Options = _options;
            return(adapter);
        }
Beispiel #2
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            if (_data.ContainsKey(binder.Name))
            {
                result = _data[binder.Name];
                var converted = ConvertResult(result);
                if (!ReferenceEquals(result, converted))
                {
                    _data[binder.Name] = result = converted;
                }

                return(true);
            }

            if (_tableName == null)
            {
                result = null;
                return(false);
            }

            if (_database != null)
            {
                var relatedAdapter = _database.GetAdapter() as IAdapterWithRelation;
                if (relatedAdapter != null && relatedAdapter.IsValidRelation(_tableName, binder.Name))
                {
                    result = GetRelatedData(binder, relatedAdapter);
                    return(true);
                }
            }
            return(base.TryGetMember(binder, out result));
        }
        private static SimpleTransaction CreateTransaction(DataStrategy database, IsolationLevel isolationLevel = IsolationLevel.Unspecified)
        {
            var adapterWithTransactions = database.GetAdapter() as IAdapterWithTransactions;

            if (adapterWithTransactions == null)
            {
                throw new NotSupportedException();
            }
            return(new SimpleTransaction(adapterWithTransactions, database, isolationLevel));
        }
Beispiel #4
0
 public SimpleQuery(DataStrategy dataStrategy, string tableName)
 {
     _dataStrategy = dataStrategy;
     if (_dataStrategy != null)
     {
         _adapter = _dataStrategy.GetAdapter();
     }
     _tableName = tableName;
     _clauses   = new SimpleQueryClauseBase[0];
 }
Beispiel #5
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var adapterWithFunctions = _dataStrategy.GetAdapter() as IAdapterWithFunctions;

            if (adapterWithFunctions != null && adapterWithFunctions.IsValidFunction(binder.Name))
            {
                var command = new ExecuteFunctionCommand(_dataStrategy.GetDatabase(), adapterWithFunctions, string.Format("{0}.{1}", _name, binder.Name),
                                                         binder.ArgumentsToDictionary(args));
                return(command.Execute(out result));
            }
            return(base.TryInvokeMember(binder, args, out result));
        }
Beispiel #6
0
        private bool TryGetMember(string name, out object result)
        {
            if (_data.ContainsKey(name))
            {
                result = _data[name];
                var converted = ConvertResult(result);
                if (!ReferenceEquals(result, converted))
                {
                    _data[name] = result = converted;
                }

                return(true);
            }

            if (_tableName == null)
            {
                result = null;
                return(false);
            }

            if (_database != null)
            {
                try
                {
                    var relatedAdapter = _database.GetAdapter() as IAdapterWithRelation;
                    if (relatedAdapter != null && relatedAdapter.IsValidRelation(_tableName, name))
                    {
                        result = GetRelatedData(name, relatedAdapter);
                        return(true);
                    }
                }
                catch (UnresolvableObjectException e)
                {
                    throw new UnresolvableObjectException(e.ObjectName, string.Format("Column '{0}' not found.", e.ObjectName), e);
                }
            }

            result = null;
            return(false);
        }
Beispiel #7
0
 public DataStrategyWithOptions(DataStrategy wrappedStrategy, OptionsBase options)
 {
     _options         = options;
     _wrappedStrategy = wrappedStrategy.Clone();
     _wrappedStrategy.GetAdapter().Options = options;
 }
 public DataStrategyWithOptions(DataStrategy wrappedStrategy, OptionsBase options)
 {
     _options = options;
     _wrappedStrategy = wrappedStrategy.Clone();
     _wrappedStrategy.GetAdapter().Options = options;
 }
 private static SimpleTransaction CreateTransaction(DataStrategy database, IsolationLevel isolationLevel = IsolationLevel.Unspecified)
 {
     var adapterWithTransactions = database.GetAdapter() as IAdapterWithTransactions;
     if (adapterWithTransactions == null) throw new NotSupportedException();
     return new SimpleTransaction(adapterWithTransactions, database, isolationLevel);
 }