Пример #1
0
        public void ManualMap()
        {
            DataType <Person> dtype = new DataType <Person>();

            DataType.AllDataTypes.Add(dtype);
            dtype.AddMember(m => m.Id);
            dtype.AddMember(m => m.Firstname);

            DataType <CustomerContact> dtype2 = new DataType <CustomerContact>();

            DataType.AllDataTypes.Add(dtype2);
            dtype2.AddMember(m => m.Id);
            dtype2.AddMember(m => m.Customer.Id);
            dtype2.AddMember(m => m.Customer.LegalName);
            dtype2.AddMember(m => m.Customer.Phone);
            DataBase.Create <CustomerContact>();

            for (int i = 0; i < 30; i++)
            {
                CustomerContact cc = new CustomerContact();
                cc.Firstname          = "Maria " + i;
                cc.Customer           = new Customer();
                cc.Customer.LegalName = "Empresa " + i;
                cc.Customer.Phone     = "Telefono " + i;

                DataBase.Table <int, CustomerContact>().Add(0, cc);
            }

            foreach (var cc in DataBase.Table <int, CustomerContact>())
            {
                Console.WriteLine(cc.Value.Firstname + " " + cc.Value.Customer.LegalName);
            }

            DataBase.Drop <CustomerContact>();
        }
Пример #2
0
		public void ManualMap()
		{
			DataType<Person> dtype = new DataType<Person>();
			DataType.AllDataTypes.Add(dtype);
			dtype.AddMember(m => m.Id);
			dtype.AddMember(m => m.Firstname);
			
			DataType<CustomerContact> dtype2 = new DataType<CustomerContact>();
			DataType.AllDataTypes.Add(dtype2);
			dtype2.AddMember(m => m.Id);
			dtype2.AddMember(m => m.Customer.Id);
			dtype2.AddMember(m => m.Customer.LegalName);
			dtype2.AddMember(m => m.Customer.Phone);
			DataBase.Create<CustomerContact>();

			for(int i = 0; i < 30; i++)
			{
				CustomerContact cc = new CustomerContact();
				cc.Firstname = "Maria " + i;
				cc.Customer = new Customer();
				cc.Customer.LegalName = "Empresa " + i;
				cc.Customer.Phone= "Telefono " + i;

				DataBase.Table<int, CustomerContact>().Add(0, cc);
			}

			foreach (var cc in DataBase.Table<int, CustomerContact>())
			{
				Console.WriteLine(cc.Value.Firstname + " " + cc.Value.Customer.LegalName);
			}
			
			DataBase.Drop<CustomerContact>();
		}
Пример #3
0
		public void ManualMapWithTables()
		{
			Table personTable = new Table("personTable");
			personTable.Columns.Add(new Column() { IsPrimaryKey = true, Name = "key", DbType = Sql.DbType.Int32 });
			personTable.Columns.Add(new Column() { Name = "name", DbType = Sql.DbType.String });
			personTable.Columns.Add(new Column() { Name = "birth", DbType = Sql.DbType.DateTime });

			DataType<Person> dtype = new DataType<Person>(personTable);
			DataType.AllDataTypes.Add(dtype);
			dtype.AddMember(m => m.Id, personTable["key"]);
			dtype.AddMember(m => m.Firstname, personTable["name"]);
			dtype.AddMember(x => x.BirthDate, personTable["birth"]);

			DataType<CustomerContact> dtype2 = new DataType<CustomerContact>();
			DataType.AllDataTypes.Add(dtype2);
			dtype2.AddMember(m => m.Id);
			dtype2.AddMember(m => m.Customer.Id);
			dtype2.AddMember(m => m.Customer.LegalName);
			dtype2.AddMember(m => m.Customer.Phone);
			DataBase.Create<CustomerContact>();

			for (int i = 0; i < 30; i++)
			{
				CustomerContact cc = new CustomerContact();
				cc.Firstname = "Maria " + i;
				cc.Customer = new Customer();
				cc.Customer.LegalName = "Empresa " + i;
				cc.Customer.Phone = "Telefono " + i;

				DataBase.Table<int, CustomerContact>().Add(0, cc);
			}

			foreach (var cc in DataBase.Table<int, CustomerContact>())
			{
				Console.WriteLine(cc.Value.Firstname + " " + cc.Value.Customer.LegalName);
			}

			DataBase.Drop<CustomerContact>();
		}