示例#1
0
		public static void Delete_ManagerNotNull_Enumerate( IKLink link )
		{
			Console.WriteLine( "\n===== Delete the employees whose manager is NOT null enumerating the results..." );

			var cmd = link.Delete( x => x.Employees )
				.Where( x => x.ManagerId != null );
			Console.WriteLine( "\n> Command => {0}", cmd );

			foreach( var obj in cmd ) Console.WriteLine( "\n> Record => {0}", obj );
			cmd.Dispose();
		}
示例#2
0
		public static void Delete_ManagerNotNull_NonQuery( IKLink link )
		{
			Console.WriteLine( "\n===== Delete the employees whose manager is NOT just returning the number..." );

			var cmd = link.Delete( x => x.Employees )
				.Where( x => x.ManagerId != null );
			Console.WriteLine( "\n> Command => {0}", cmd );

			int n = cmd.Execute();
			Console.WriteLine( "\n> Result => {0}", n );

			cmd.Dispose();
		}
示例#3
0
		public static void Delete_JamesBond_Enumerate( IKLink link )
		{
			Console.WriteLine( "\n===== Delete James Bond enumerating the results..." );

			var cmd = link.Delete( x => x.Employees )
				.Where( x => x.Id == "007" );
			Console.WriteLine( "\n> Command => {0}", cmd );

			foreach( var obj in cmd ) Console.WriteLine( "\n> Record => {0}", obj );
			cmd.Dispose();
		}
示例#4
0
		public static void Test_Scenario( IKLink link )
		{
			Console.WriteLine( "\n===== Cleaning the scenario ...[Enter]" ); Console.ReadLine();
			link.Delete( x => x.Employees ).Execute();
			link.Delete( x => x.Countries ).Execute();
			link.Delete( x => x.Regions ).Execute();

			Console.WriteLine( "\n===== Persisting the hierarchy through a leaf object...[Enter]" ); Console.ReadLine();
			Region rEMEA = new Region() { Id = "200", Name = "EMEA" };
			Region rNE = new Region() { Id = "210", Name = "North Europe", Parent = rEMEA };
			Country cUK = new Country() { Id = "uk", Name = "United Kingdom", Region = rNE };
			Employee eM = new Employee() { Id = "M", Country = cUK, FirstName = "M" };

			Employee e007 = new Employee() { Id = "007", Country = cUK, FirstName = "James", LastName = "Bond", Manager = eM };
			e007.BirthDate = new CalendarDate( 1940, 1, 1 );
			e007.Active = true;
			e007.JoinDate = new CalendarDate( 1965, 1, 1 );
			e007.StartTime = new ClockTime( 8, 0, 0 );
			e007.Photo = new byte[] { 0, 0, 7 };
			e007 = link.Insert( e007 ).Execute();

			Console.WriteLine( "\n>> Region EMEA: {0}", rEMEA );
			Console.WriteLine( "\n>> Region North Europe: {0}", rNE );
			Console.WriteLine( "\n>> Country UK: {0}", cUK );
			Console.WriteLine( "\n>> Employee M: {0}", eM );
			Console.WriteLine( "\n>> Employee 007: {0}", e007 );

			Console.WriteLine( "\n===== Creating another set ...[Enter]" ); Console.ReadLine();
			Region rAMS = new Region() { Id = "100", Name = "Americas" }; link.Insert( rAMS ).Execute();
			Region rNA = new Region() { Id = "110", Name = "North America", Parent = rAMS }; link.Insert( rNA ).Execute();
			Console.WriteLine( "\n> Inserted theatre: {0}", rAMS );

			Country cUSA = new Country() { Id = "us", Name = "United States of America", Region = rNA };
			Employee e009 = new Employee() { Id = "009", FirstName = "John", LastName = "Smith", Country = cUSA };
			e009 = link.Insert( e009 ).Execute();
			Console.WriteLine( "\n> Inserted spy: {0}", e009 );

			Console.WriteLine( "\n===== An update with change in the key columns ...[Enter]" ); Console.ReadLine();
			e009.Country = cUK; e009 = link.Update( e009 ).Execute();
			cUSA.Employees.Remove( e009 ); link.Update( cUSA ).Execute();

			Console.WriteLine( "\n> Updated spy: {0}", e009 );
			Console.WriteLine( "\n>> UK Employees: {0}", TypeHelper.ToString( cUK.Employees ) );
			Console.WriteLine( "\n>> USA Employees: {0}", TypeHelper.ToString( cUSA.Employees ) );

			Console.WriteLine( "\n===== Removing by cascading deletion ...[Enter]" ); Console.ReadLine();
			link.Delete( rEMEA ).Execute();
			link.Delete( rAMS).Execute();
		}
示例#5
0
		public static void Test_Delete_Cascading( IKLink link )
		{
			Console.WriteLine( "\n===== Delete All by Cascading ..." );
			Region reg = link.Find<Region>( x => x.Id == "000" );
			reg = link.Delete( reg ).Execute();

			Console.WriteLine( "\n>> Region: {0}", reg == null ? "<null>" : reg.ToString() );
		}
示例#6
0
		public static void Test_Delete( IKLink link, Employee emp )
		{
			Console.WriteLine( "\n===== Delete..." );
			emp = link.Delete( emp ).Execute(); Console.WriteLine( "\n> Deleted: ", emp );
		}
示例#7
0
		public static void Test_Delete( IKLink link, Region reg )
		{
			Console.WriteLine( "\n===== Deleting a region ..." ); Console.ReadLine();
			reg = link.Delete( reg ).Execute();
			Console.WriteLine( "\n>> Delete Region: {0}", reg == null ? "null" : reg.ToString() );
		}