Ejemplo n.º 1
0
        public void Inequality_Tag()
        {
            var cmd1 = new DbCommandDescriptor(1, "a");
            var cmd2 = new DbCommandDescriptor(2, "a");

            Assert.NotEqual(cmd1, cmd2);
        }
Ejemplo n.º 2
0
        public void Equality_Params_Null()
        {
            var cmd1 = new DbCommandDescriptor("a", null);
            var cmd2 = new DbCommandDescriptor("a", null);

            Assert.Equal(cmd1.GetHashCode(), cmd2.GetHashCode());
        }
        public void Equality_Params_Null()
        {
            var cmd1 = new DbCommandDescriptor("a", null);
            var cmd2 = new DbCommandDescriptor("a", null);

            Assert.Equal(cmd1.GetHashCode(), cmd2.GetHashCode());
        }
Ejemplo n.º 4
0
        public void Equality_Params()
        {
            var cmd1 = new DbCommandDescriptor("a", 1, 2, 3);
            var cmd2 = new DbCommandDescriptor("a", 1, 2, 3);

            Assert.Equal(cmd1.GetHashCode(), cmd2.GetHashCode());
            Assert.Equal(cmd1, cmd2);
        }
        public ScalarMappedAssociationLoader(
            DbCommandDescriptor command, IDbColumnBinder binder)
        {
            Precondition.Require(command, () => Error.ArgumentNull("command"));

            _command = command;
            _binder  = binder;
        }
        public void Inequality_SqlOnly()
        {
            var cmd1 = new DbCommandDescriptor("a");
            var cmd2 = new DbCommandDescriptor("b");

            Assert.NotEqual(cmd1, cmd2);
            Assert.False(cmd1.Equals((object)cmd2));
        }
        public void Equality_Params()
        {
            var cmd1 = new DbCommandDescriptor("a", 1, 2, 3);
            var cmd2 = new DbCommandDescriptor("a", 1, 2, 3);

            Assert.Equal(cmd1.GetHashCode(), cmd2.GetHashCode());
            Assert.Equal(cmd1, cmd2);
        }
Ejemplo n.º 8
0
        public void Inequality_SqlOnly()
        {
            var cmd1 = new DbCommandDescriptor("a");
            var cmd2 = new DbCommandDescriptor("b");

            Assert.NotEqual(cmd1, cmd2);
            Assert.False(cmd1.Equals((object)cmd2));
        }
        public void DictionaryKey()
        {
            var cmd1 = new DbCommandDescriptor("abc", new { a = 123 });
            var cmd2 = new DbCommandDescriptor("abc", new { a = 123 });

            var dict = new Dictionary<object, object>();
            dict[cmd1] = "ok";

            Assert.Equal("ok", dict[cmd2]);
        }
Ejemplo n.º 10
0
        public void Equality_SqlOnly()
        {
            var cmd1 = new DbCommandDescriptor("a");
            var cmd2 = new DbCommandDescriptor("a");

            Assert.Equal(cmd1.GetHashCode(), cmd2.GetHashCode());
            Assert.Equal(cmd1, cmd2);

            Assert.True(cmd1.Equals((object)cmd2));
        }
Ejemplo n.º 11
0
        public void Equality_SqlOnly()
        {
            var cmd1 = new DbCommandDescriptor("a");
            var cmd2 = new DbCommandDescriptor("a");

            Assert.Equal(cmd1.GetHashCode(), cmd2.GetHashCode());
            Assert.Equal(cmd1, cmd2);

            Assert.True(cmd1.Equals((object)cmd2));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Executes the provided <paramref name="command"/>
 /// against the provided data source and returns the result.
 /// </summary>
 /// <param name="context">Provides the current operation context.</param>
 /// <param name="command">The command instance to execute.</param>
 protected override TEntity ExecuteCommand(DbOperationContext context, DbCommandDescriptor command)
 {
     return(context.Provider.Execute(command).AsDataReader <TEntity>(reader => {
         if (reader.Read())
         {
             return Serializer.Deserialize(reader);                      // TODO: Этого мало, необходимо сделать обработку ResultShape'ов.
         }
         return default(TEntity);
     }));
 }
Ejemplo n.º 13
0
        public void DictionaryKey()
        {
            var cmd1 = new DbCommandDescriptor("abc", new { a = 123 });
            var cmd2 = new DbCommandDescriptor("abc", new { a = 123 });

            var dict = new Dictionary <object, object>();

            dict[cmd1] = "ok";

            Assert.Equal("ok", dict[cmd2]);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Executes the provided <paramref name="command"/>
 /// against the provided data source and returns the result.
 /// </summary>
 /// <param name="context">Provides the current operation context.</param>
 /// <param name="command">The command instance to execute.</param>
 protected override IEnumerable <TEntity> ExecuteCommand(DbOperationContext context,
                                                         DbCommandDescriptor command)
 {
     return(context.Provider.Execute(command).AsDataReader(reader => {
         List <TEntity> collection = new List <TEntity>(BufferSize);
         while (reader.Read())
         {
             collection.Add(Serializer.Deserialize(reader));                     // TODO: Этого мало, необходимо сделать обработку ResultShape'ов.
         }
         return collection;
     }));
 }
Ejemplo n.º 15
0
        public void Inequality_Params()
        {
            var cmd1 = new DbCommandDescriptor("a", 1, 2);
            var cmd2 = new DbCommandDescriptor("a", 1, "2");
            var cmd3 = new DbCommandDescriptor("a", 1, null);
            var cmd4 = new DbCommandDescriptor("a", null, 2);
            var cmd5 = new DbCommandDescriptor("a", 1);
            var cmd6 = new DbCommandDescriptor("a", 1, 2, 3);

            Assert.NotEqual(cmd1, cmd2);
            Assert.NotEqual(cmd1, cmd3);
            Assert.NotEqual(cmd1, cmd4);
            Assert.NotEqual(cmd1, cmd5);
            Assert.NotEqual(cmd1, cmd6);
        }
Ejemplo n.º 16
0
        public void Inequality_Params()
        {
            var cmd1 = new DbCommandDescriptor("a", 1, 2);
            var cmd2 = new DbCommandDescriptor("a", 1, "2");
            var cmd3 = new DbCommandDescriptor("a", 1, null);
            var cmd4 = new DbCommandDescriptor("a", null, 2);
            var cmd5 = new DbCommandDescriptor("a", 1);
            var cmd6 = new DbCommandDescriptor("a", 1, 2, 3);

            Assert.NotEqual(cmd1, cmd2);
            Assert.NotEqual(cmd1, cmd3);
            Assert.NotEqual(cmd1, cmd4);
            Assert.NotEqual(cmd1, cmd5);
            Assert.NotEqual(cmd1, cmd6);
        }
        /// <summary>
        /// Executes the provided <paramref name="command"/>
        /// against the provided data source and returns the result.
        /// </summary>
        /// <param name="context">Provides the current operation context.</param>
        /// <param name="command">The command instance to execute.</param>
        protected override IEnumerable <TEntity> ExecuteCommand(DbOperationContext context,
                                                                DbCommandDescriptor command)
        {
            return(context.Provider.Execute(command).AsDataReader(reader => {
                List <TEntity> collection = new List <TEntity>(BufferSize);
                int count = 0;

                while (reader.Read())
                {
                    collection.Add(Serializer.Deserialize(reader));                     // TODO: Добавить поддержку ResultShapes.
                }
                if (reader.NextResult() && reader.Read())
                {
                    count = reader.GetValue <int>(0);
                }

                return collection.ToSubset(count);
            }));
        }
Ejemplo n.º 18
0
 protected override int ExecuteCommand(DbOperationContext context, DbCommandDescriptor command)
 {
     return(context.Provider.Execute(command).AsNonQuery());
 }
Ejemplo n.º 19
0
        public void Inequality_Tag()
        {
            var cmd1 = new DbCommandDescriptor(1, "a");
            var cmd2 = new DbCommandDescriptor(2, "a");

            Assert.NotEqual(cmd1, cmd2);
        }
Ejemplo n.º 20
0
 protected override DbQueryResult ExecuteCommand(DbOperationContext context, DbCommandDescriptor command)
 {
     return(context.Provider.Execute(command).AsDataReader(reader => new DbQueryResult(reader)));
 }
 public Operation(DbCommandDescriptor command)
     : base()
 {
     _command = command;
 }
 public SingleMappedAssociationLoader(DbCommandDescriptor command)
 {
     Precondition.Require(command, () => Error.ArgumentNull("command"));
     _command = command;
 }