本文整理汇总了C#中Company.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Company.Save方法的具体用法?C# Company.Save怎么用?C# Company.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company.Save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateCompany
public static void GenerateCompany(int count)
{
for (int i = 0; i < count; i++)
{
Company c = new Company();
c.CompanyName = RandomString(20);
c.Save();
}
}
示例2: UpdateDatabaseAfterUpdateSchema
public override void UpdateDatabaseAfterUpdateSchema()
{
base.UpdateDatabaseAfterUpdateSchema();
Employee userAdmin = Session.FindObject<Employee>(new BinaryOperator("UserName", "Admin"));
if (new XPCollection<Company>(Session).Count == 0)
{
using (Role administratorRole = new Role(Session) { Name = "Administrator role" })
{
administratorRole.AddPermission(new EditModelPermission());
administratorRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
administratorRole.Save();
using (Role userRole = new Role(Session) { Name = "User" })
{
userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.Navigate));
userRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.Read));
userRole.Save();
}
userAdmin = new Employee(Session);
userAdmin.UserName = "Admin";
userAdmin.FirstName = "Admin";
userAdmin.LastName = "";
userAdmin.Roles.Add(administratorRole);
userAdmin.Save();
using (Branch branch1 = new Branch(Session) { Acronym = "WTPR", Branchname = "Roadmax Head Office" })
{
using (Company company1 = new Company(Session) { CompanyName = "Roadmax Marketing Inc.", Acronym = "WTPR" })
{
company1.Employees.Add(userAdmin);
company1.Branches.Add(branch1);
company1.Save();
ImportData(company1);
}
}
}
using (Currency curr = new Currency(Session) { CurrencyName = "Peso", CurrencyRate = 1 })
{
curr.Save();
}
using (VatCategory vat = new VatCategory(Session) { Acronym = "VAT", Description = "Vatable", Rate = 12 })
{
vat.Save();
}
}
//importReport("SOHeaderPrintOut");
}
示例3: TestCompanyCRUD
public void TestCompanyCRUD()
{
List<Company> list = Company.Query("code = 'testcode'");
foreach (Company c in list)
{
c.Destory();
}
list = Company.Query();
long count = list.Count;
Company com = new Company();
com.Code = "testcode";
com.Name = "testname";
com.Doc = "沪";
com.Input = "X";
com.Output = "X";
com.ParentID = Company.Query("input <> 'X' and output <> 'X'")[0].ID;
for (int i = 0; i < 10; i++)
{
CompanyDetail d = new CompanyDetail();
d.BankID = Bank.Query()[0].ID;
d.Account = i.ToString();
d.Balance = i;
d.Credit = i;
com.DetailList.Add(d);
}
Assert.IsTrue(com.Save());
Assert.IsTrue(com.ID > 0);
Company q = Company.CreateByID(com.ID);
Assert.IsTrue(q.ID == com.ID);
Assert.IsTrue(q.DetailList.Count == 10);
q.DetailList.RemoveAt(0);
q.Save();
list = q.Find("code = 'testcode'");
Assert.IsTrue(list.Count == 1);
Assert.IsTrue(list[0].DetailList.Count == 9);
list = Company.Query();
Assert.IsTrue(list.Count == count + 1);
com.Destory();
list = Company.Query();
Assert.IsTrue(list.Count == count);
}
示例4: ComponentAttribute
public void ComponentAttribute()
{
Company company = new Company("Castle Corp.");
company.Address = new PostalAddress(
"Embau St., 102", "Sao Paulo", "SP", "040390-060");
company.Save();
Company[] companies = Company.FindAll();
Assert.IsNotNull(companies);
Assert.AreEqual(1, companies.Length);
Company corp = companies[0];
Assert.IsNotNull(corp.Address);
Assert.AreEqual(corp.Address.Address, company.Address.Address);
Assert.AreEqual(corp.Address.City, company.Address.City);
Assert.AreEqual(corp.Address.State, company.Address.State);
Assert.AreEqual(corp.Address.ZipCode, company.Address.ZipCode);
}
示例5: ProgrammerTest
public void ProgrammerTest()
{
var address = new Address("56 Main St", "Mesa", "AZ", "85225");
var customer = new Customer("John", "Doe", address);
var company = new Company("Alliance Reservations Network", address);
Assert.IsNullOrEmpty(customer.Id);
customer.Save();
Assert.IsNotNullOrEmpty(customer.Id);
Assert.IsNullOrEmpty(company.Id);
company.Save();
Assert.IsNotNullOrEmpty(company.Id);
Customer savedCustomer = Customer.Find(customer.Id);
Assert.IsNotNull(savedCustomer);
Assert.AreSame(customer.Address, address);
Assert.AreEqual(savedCustomer.Address, address);
Assert.AreEqual(customer.Id, savedCustomer.Id);
Assert.AreEqual(customer.FirstName, savedCustomer.FirstName);
Assert.AreEqual(customer.LastName, savedCustomer.LastName);
Assert.AreEqual(customer, savedCustomer);
Assert.AreNotSame(customer, savedCustomer);
Company savedCompany = Company.Find(company.Id);
Assert.IsNotNull(savedCompany);
Assert.AreSame(company.Address, address);
Assert.AreEqual(savedCompany.Address, address);
Assert.AreEqual(company.Id, savedCompany.Id);
Assert.AreEqual(company.Name, savedCompany.Name);
Assert.AreEqual(company, savedCompany);
Assert.AreNotSame(company, savedCompany);
customer.Delete();
Assert.IsNullOrEmpty(customer.Id);
Assert.IsNull(Customer.Find(customer.Id));
company.Delete();
Assert.IsNullOrEmpty(company.Id);
Assert.IsNull(Company.Find(company.Id));
}
示例6: ComponentAttribute
public void ComponentAttribute()
{
using (new SessionScope()) {
var company = new Company("Castle Corp.") {
Address = new PostalAddress(
"Embau St., 102", "Sao Paulo", "SP", "040390-060")
};
company.Save();
var companies = Company.FindAll().ToArray();
Assert.IsNotNull(companies);
Assert.AreEqual(1, companies.Length);
var corp = companies.First();
Assert.IsNotNull(corp.Address);
Assert.AreEqual(corp.Address.Address, company.Address.Address);
Assert.AreEqual(corp.Address.City, company.Address.City);
Assert.AreEqual(corp.Address.State, company.Address.State);
Assert.AreEqual(corp.Address.ZipCode, company.Address.ZipCode);
}
}
示例7: HasManyAndBelongsToMany
public void HasManyAndBelongsToMany()
{
long id;
using (new SessionScope()) {
var company = new Company("Castle Corp.") {
Address =
new PostalAddress("Embau St., 102", "Sao Paulo", "SP", "040390-060")
};
var person = new Person {Name = "ayende"};
company.People.Add(person);
person.Save();
company.Save();
id = company.Id;
}
using (new SessionScope()) {
var fromDB = Company.Find(id);
Assert.AreEqual(1, fromDB.People.Count);
Assert.AreEqual("ayende", fromDB.People.First().Name);
}
}
示例8: HasManyAndBelongsToMany
public void HasManyAndBelongsToMany()
{
Company company = new Company("Castle Corp.");
company.Address = new PostalAddress(
"Embau St., 102", "Sao Paulo", "SP", "040390-060");
company.Save();
Person person = new Person();
person.Name = "ayende";
person.Companies.Add(company);
company.People.Add(person);
person.Save();
Company fromDB = Company.FindFirst();
Assert.AreEqual(1, fromDB.People.Count);
Assert.AreEqual("ayende", new List<Person>(fromDB.People)[0].Name);
}