本文整理汇总了C#中Person._AsDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# Person._AsDictionary方法的具体用法?C# Person._AsDictionary怎么用?C# Person._AsDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person._AsDictionary方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public void Delete()
{
var db = ConnectTo.Sql2005(Config.TestDBConnectionString);
var person = new Person();
person.FirstName = "bob";
person.LastName = "morris";
var key = db.Insert("Person", person._AsDictionary());
db.Delete("Person", key);
Assert.AreEqual(0, db.RawRead("Person", key).Count());
}
示例2: Insert
public void Insert()
{
var db = ConnectTo.Sql2005(Config.TestDBConnectionString);
var contents = db.ReadAll<Person>();
var person = new Person();
person.FirstName = "test";
person.LastName = "person";
db.Insert("Person", person._AsDictionary());
Assert.AreEqual(contents.Count() + 1, db.ReadAll<Person>().Count());
}
示例3: Update
public void Update()
{
var db = ConnectTo.Sql2005(Config.TestDBConnectionString);
var person = new Person();
person.FirstName = "test";
person.LastName = "person";
var keys = db.Insert("Person", person._AsDictionary());
//Retrieve the saved person so we can verify it saved with our intended data
var retrieved = db.RawRead("Person", keys).First();
Assert.AreEqual(person.FirstName, retrieved["FirstName"]);
Assert.AreEqual(person.LastName, retrieved["LastName"]);
person.FirstName = "newFirst";
person.LastName = "newLastName";
//Update and retrieve the person again so we can verify that the Update worked
db.Update("Person", person._AsDictionary(), keys);
retrieved = db.RawRead("Person", keys).First();
Assert.AreEqual(person.FirstName, retrieved["FirstName"]);
Assert.AreEqual(person.LastName, retrieved["LastName"]);
}
示例4: TransactionSuccessful
public void TransactionSuccessful()
{
var db = ConnectTo.Sql2005(Config.TestDBConnectionString);
var transaction = db.BeginTransaction();
var person = new Person();
person.FirstName = "test";
person.LastName = "person";
var keys = transaction.Insert("Person", person._AsDictionary());
transaction.Commit();
Assert.AreEqual(1, db.RawRead("Person", keys).Count());
}
示例5: TransactionAbandoned
public void TransactionAbandoned()
{
var keys = new Dictionary<string, object>();
var db = ConnectTo.Sql2005(Config.TestDBConnectionString);
using(var transaction = db.BeginTransaction())
{
var person = new Person();
person.FirstName = "test";
person.LastName = "person";
keys = transaction.Insert("Person", person._AsDictionary());
}
var conn = ConnectTo.Sql2005(Config.TestDBConnectionString);
Assert.AreEqual(0, conn.RawRead("Person", keys).Count());
}
示例6: TransactionRollback
public void TransactionRollback()
{
var db = ConnectTo.Sql2005(connString);
var transaction = db.BeginTransaction();
var person = new Person();
person.FirstName = "test";
person.LastName = "person";
var keys = transaction.Insert("Person", person._AsDictionary());
transaction.Rollback();
Assert.AreEqual(0, db.RawRead("Person", keys).Count());
}