Exemple #1
0
        public void Can_retrieve_ServerGuid()
        {
            using (var db = OpenDbConnection())
                using (var cmd = db.CreateCommand())
                {
                    db.DropAndCreateTable <ServerGuid>();

                    var obj = new ServerGuid {
                        Name = "foo"
                    };

                    cmd.GetDialectProvider().PrepareParameterizedInsertStatement <ServerGuid>(cmd,
                                                                                              insertFields: db.GetDialectProvider().GetNonDefaultValueInsertFields <ServerGuid>(obj));

                    cmd.CommandText = cmd.CommandText.Replace("VALUES", "OUTPUT inserted.Id VALUES");

                    cmd.GetDialectProvider().SetParameterValues <ServerGuid>(cmd, obj);

                    var id = (Guid)cmd.ExecuteScalar();

                    Assert.That(id, Is.Not.EqualTo(default(Guid)));

                    var insertedRow = db.SingleById <ServerGuid>(id);

                    Assert.That(insertedRow.Name, Is.EqualTo("foo"));
                }
        }
Exemple #2
0
 public void Write(Stream s)
 {
     using (var writer = new BinaryWriter(s, Encoding.Unicode, leaveOpen: true))
     {
         writer.Write(StructureSize);
         writer.Write(SecurityMode);
         writer.Write(DialectRevision);
         writer.Write((ushort)0);
         writer.Write(ServerGuid.ToByteArray());
         writer.Write(Capabilites);
         writer.Write(MaxTransactSize);
         writer.Write(MaxReadSize);
         writer.Write(MaxWriteSize);
         writer.Write(SystemTime);
         writer.Write(ServerStartTime);
         writer.Write(SecurityBufferOffset);
         writer.Write(SecurityBufferLength);
         writer.Write((uint)0);
     }
 }
 public override int GetHashCode()
 {
     unchecked {
         return(((Key != null ? Key.GetHashCode() : 0) * 397) ^ (ServerGuid != null ? ServerGuid.GetHashCode() : 0));
     }
 }