本文整理汇总了C#中Company.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Company.Create方法的具体用法?C# Company.Create怎么用?C# Company.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company.Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExplicitFlushInsideSecondTransactionProblem
public void ExplicitFlushInsideSecondTransactionProblem()
{
var comp1 = new Company("comp1");
var comp2 = new Company("comp2");
using(new SessionScope())
{
comp1.Create();
comp2.Create();
}
using(new SessionScope(FlushAction.Never))
{
using(var tx = new TransactionScope(ondispose: OnDispose.Rollback))
{
var comp2a = Company.Find(comp2.Id);
comp2a.Name = "changed";
tx.VoteCommit();
}
using(var scope = new TransactionScope(ondispose: OnDispose.Rollback))
{
var changedCompanies = AR.FindAllByProperty<Company>("Name", "changed");
Assert.AreEqual(1, changedCompanies.Count());
var e2a = changedCompanies.First();
e2a.Delete();
scope.Flush();
Assert.AreEqual(0, AR.FindAllByProperty<Company>("Name", "changed").Count());
}
}
}
示例2: Main
public static void Main()
{
ActiveRecordStarter.Initialize(
new XmlConfigurationSource("../appconfig.xml"),
typeof(Company), typeof(Client), typeof(Firm), typeof(Person) );
// If you want to let AR to create the schema
ActiveRecordStarter.CreateSchema();
// Common usage
Client.DeleteAll();
Firm.DeleteAll();
Company.DeleteAll();
using(new SessionScope())
{
Company company = new Company("Stronghold");
company.Create();
Firm firm = new Firm("Johnson & Norman");
firm.Create();
Client client = new Client("hammett", firm);
client.Create();
}
// Now let's load
using(new SessionScope())
{
Company[] companies = Company.FindAll();
Debug.Assert(companies.Length == 3);
Firm[] firms = Firm.FindAll();
Debug.Assert(firms.Length == 1);
Client[] clients = Client.FindAll();
Debug.Assert(clients.Length == 1);
}
// Drop the schema if you want
// ActiveRecordStarter.DropSchema();
}
示例3: ReportedProblemOnForum
public void ReportedProblemOnForum()
{
using(new TransactionScope())
{
var comp1 = new Company("comp1");
comp1.Create();
var comp2 = new Company("comp2");
comp2.Create();
}
}