本文整理汇总了C#中Realm.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Realm.Add方法的具体用法?C# Realm.Add怎么用?C# Realm.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Realm
的用法示例。
在下文中一共展示了Realm.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
Realm.DeleteRealm(RealmConfiguration.DefaultConfiguration);
realm = Realm.GetInstance();
// we don't keep any variables pointing to these as they are all added to Realm
using (var trans = realm.BeginWrite())
{
var o1 = realm.Add(new Owner { Name = "Tim" });
var d1 = realm.Add(new Dog
{
Name = "Bilbo Fleabaggins",
Color = "Black"
});
o1.TopDog = d1; // set a one-one relationship
o1.Dogs.Add(d1);
var d2 = realm.Add(new Dog
{
Name = "Earl Yippington III",
Color = "White"
});
o1.Dogs.Add(d2);
// lonely people and dogs
realm.Add(new Owner
{
Name = "Dani" // the dog-less
});
realm.Add(new Dog // will remain unassigned
{
Name = "Maggie Mongrel",
Color = "Grey"
});
trans.Commit();
}
}
示例2: AddDummyData
private static void AddDummyData(Realm realm)
{
for (var i = 0; i < 1000; i++)
{
realm.Write(() =>
{
realm.Add(new IntPrimaryKeyWithValueObject
{
Id = i,
StringValue = "Super secret product " + i
});
});
}
for (var i = 0; i < 500; i++)
{
realm.Write(() =>
{
var item = realm.Find<IntPrimaryKeyWithValueObject>(2 * i);
realm.Remove(item);
});
}
}