public static TRecord GetByKey <TRecord, TKeyCollection>(
     this RecordReader <TRecord, TKeyCollection> reader,
     Func <TKeyCollection, KeyInfo> keySelector,
     System.Linq.Expressions.Expression <Func <TRecord, bool> > whereExpression = null,
     LockMode lockMode = LockMode.None)
     where TRecord : Record <TRecord>
     where TKeyCollection : KeyCollection <TRecord>, new()
 {
     return(reader.GetByKey(
                keySelector == null ? null : keySelector(reader.Keys),
                whereExpression,
                lockMode));
 }
 public static TRecord GetByKeyValue <TRecord, TKeyCollection>(
     this RecordReader <TRecord, TKeyCollection> reader,
     Func <TKeyCollection, KeyValue> keyValueSelector,
     LockMode lockMode = LockMode.None)
     where TRecord : Record <TRecord>
     where TKeyCollection : KeyCollection <TRecord>, new()
 {
     if (keyValueSelector == null)
     {
         throw new ArgumentNullException();
     }
     return(reader.GetByKeyValue(
                keyValueSelector(reader.Keys),
                lockMode));
 }
Beispiel #3
0
            static void ValidateStat(RecordReader <TRecord, TKeyCollection> manager)
            {
                var keySpecs = new List <KeySpec>();

                foreach (var keySpec in manager._stat.KeySpecs)
                {
                    keySpecs.Add(keySpec);
                    if (!keySpec.IsSegmentKey)
                    {
                        var fields = manager.Operator.RecordInfo.Fields.Where(f => f.KeySegments.Any(a => a.KeyNumber == keySpec.Number));
                        if (fields.Count() != keySpecs.Count())
                        {
                            throw new InvalidDefinitionException();
                        }
                        foreach (var field in fields)
                        {
                            var tmpKeySpec = keySpecs.SingleOrDefault(s => s.Position == field.Position && s.Length == field.Length);
                            if (tmpKeySpec == null)
                            {
                                throw new InvalidDefinitionException();
                            }
                            else
                            {
                                keySpecs.Remove(tmpKeySpec);
                            }
                        }
                        if (keySpecs.Count != 0)
                        {
                            throw new InvalidDefinitionException();
                        }
                    }
                }
                if (keySpecs.Count != 0)
                {
                    throw new InvalidDefinitionException();
                }
            }
Beispiel #4
0
 public Connection(RecordReader <TRecord, TKeyCollection> manager)
 {
     if (manager._connection == null)
     {
         if (manager.CheckTransaction())
         {
             manager._connection          = new Connection();
             manager._connection._manager = manager;
         }
         else
         {
             _manager = manager;
         }
         if (!manager.Operator.IsOpened)
         {
             manager.Operator.Open();
             if (manager._stat == null)
             {
                 manager._stat = manager.Operator.Stat;
                 ValidateStat(manager);
             }
         }
     }
 }