// ========================================================
namespace Kerosene.ORM.WCF.Test.Client
{
using Kerosene.ORM.Core;
using Kerosene.ORM.SqlServer.v2008.Concrete;
using Kerosene.ORM.SqlServer.v2012.Concrete;
using Kerosene.ORM.Test;
using Kerosene.Tools;
using System;
// ====================================================
class Program
{
static void Main(string[] args)
{
// Just in case...
DebugHelper.Initialize();
ConsoleHelper.Header(true, "\n\n=== Press [Enter] to start WCF client ... ");
// Registering the engines our app will use...
KEngineFactory.Register(new KEngineSqlServer2008());
KEngineFactory.Register(new KEngineSqlServer2012());
// Initializing the types to use for WCF serialization...
KTypesWCF.Initialize();
KTypesWCF.RegisterType(typeof(CalendarDate));
KTypesWCF.RegisterType(typeof(ClockTime));
// Creating a connection package the server can use to adapt the link created for this client...
dynamic package = new DeepObject();
package.UserName = "My User Name";
package.Password = "My Password";
package.WhenDate = CalendarDate.Now;
package.WhenTime = ClockTime.Now;
Console.WriteLine("\n> Package = {0}", package);
// Locating an engine that represents the underlying database type at the server...
var provider = "SqlClient";
var version = "11";
var engine = KEngineFactory.Locate(provider, version);
// Use the endpoint on you App.config file
var endpoint = "Service_OnTcp_Endpoint";
// Creating the link and connecting it automatically...
var link = new KLinkWCF(engine, endpoint, package);
// Do not forget to register the allowed transformers...
link.AddTransformer<CalendarDate>(x => x.ToDateTime());
link.AddTransformer<ClockTime>(x => x.ToString());
Console.WriteLine("\n> Link = {0}", link);
// Comment out the tests you want to execute...
bool pressEnter = true;
//Test_DynamicRecords.Raw_Query(link, pressEnter);
//Test_DynamicRecords.Raw_Query_Multiple_Tables(link, pressEnter);
//Test_DynamicRecords.Raw_Insert_JamesBond_Enumerate(link, pressEnter);
//Test_DynamicRecords.Raw_Delete_JamesBond_Enumerate(link, pressEnter);
//Test_DynamicRecords.Raw_Delete_JamesBond_No_Enumerate(link, pressEnter);
//Test_DynamicRecords.Raw_Stored_Procedure(link, pressEnter);
//Has no sense in a WCF context as the server side is a completely remote machine...
//Test_DynamicRecords.With_Transaction_Scope(link, pressEnter);
//Has no sense because in a WCF context the client has no notion of a direct/physical transaction...
//Test_DynamicRecords.With_External_Transaction(link, pressEnter);
//Test_DynamicRecords.With_Link_Transaction(link, pressEnter);
//Test_DynamicRecords.Query_Basic(link, pressEnter);
//Test_DynamicRecords.Query_Using_Dynamic_And_Indexed_Columns(link, pressEnter);
//Test_DynamicRecords.Query_Using_Complex_Tags(link, pressEnter);
//Test_DynamicRecords.Query_From_Multiple_Tables(link, pressEnter);
//Test_DynamicRecords.Query_Using_In_Operator(link, pressEnter);
//Test_DynamicRecords.Query_Using_NotIn_Operator(link, pressEnter);
//Test_DynamicRecords.Query_With_Chained_Froms(link, pressEnter);
//Test_DynamicRecords.Query_With_Several_Joins(link, pressEnter);
//Test_DynamicRecords.Query_Select_Distinct(link, pressEnter);
//Test_DynamicRecords.Query_With_Command_As_Source(link, pressEnter);
//Test_DynamicRecords.Query_With_Simulated_SkipTake(link, pressEnter);
//Test_DynamicRecords.Query_With_SkipTake(link, pressEnter);
//Test_DynamicRecords.Query_Getting_One_Value(link, pressEnter);
//Test_DynamicRecords.Query_With_Extended_Rounded_Syntax(link, pressEnter);
//Test_DynamicRecords.Query_With_Extended_Square_Syntax(link, pressEnter);
//Test_DynamicRecords.Insert_James_Bond_Enumerate(link, pressEnter);
//Test_DynamicRecords.Delete_James_Bond_Enumerate(link, pressEnter);
//Test_DynamicRecords.Delete_JamesBond_No_Enumerate(link, pressEnter);
//Test_DynamicRecords.Update_Several_Rows(link, pressEnter);
//Test_DynamicRecords.Delete_Manager_NotNull_Enumerate(link, pressEnter);
//Test_DynamicRecords.Delete_Manager_NotNull_No_Enumerate(link, pressEnter);
//Test_DynamicRecords.Query_With_Conversion_To_Anonymous(link, pressEnter);
//Test_DynamicRecords.Query_With_Conversion_To_Type(link, pressEnter);
//Test_DynamicRecords.Query_With_Complex_And_Recursive_Conversion(link, pressEnter);
//Test_DynamicRecords.Nested_Updates_Avoiding_Foreign_Keys(link, pressEnter);
//Test_DynamicRecords.Update_With_Row_Version(link, pressEnter);
//Test_DynamicRecords.Query_Performance_Regions(link, pressEnter);
// Remember to comment-out the following line if any of the map tests are also executed...
Test_LazyMaps.Register_Maps(link, pressEnter, show: true);
//Test_LazyMaps.Validate_Maps(link, pressEnter);
//Test_LazyMaps.Clone_And_Dispose_Maps(link, pressEnter);
//Test_LazyMaps.Region_Find_Root(link, pressEnter);
//Test_LazyMaps.Region_List_All(link, pressEnter);
//Test_LazyMaps.Region_Find_From_Cache(link, pressEnter);
//Test_LazyMaps.Region_Find_Used_As_Query(link, pressEnter);
//Test_LazyMaps.Region_Refresh_From_Cache(link, pressEnter);
//Test_LazyMaps.Region_Refresh_Used_As_Query(link, pressEnter);
//Test_LazyMaps.Region_Delete_Root_Isolated(link, pressEnter);
//Test_LazyMaps.Region_Delete_Root(link, pressEnter);
//Test_LazyMaps.Region_Delete_Arbitrary_Instance(link, pressEnter);
//Test_LazyMaps.Region_Insert_Root_With_Childs(link, pressEnter);
//Test_LazyMaps.Region_Insert_Child_With_Root(link, pressEnter);
//Test_LazyMaps.Employee_Insert_Lateral(link, pressEnter);
//Test_LazyMaps.Region_Update_Root(link, pressEnter);
//Test_LazyMaps.Region_Update_Root_From_Child_Update(link, pressEnter);
//Test_LazyMaps.Region_Insert_By_Update_Parent(link, pressEnter);
Test_LazyMaps.Query_Performance_Regions(link, pressEnter);
ConsoleHelper.Header(true, "\n\n=== Press [Enter] to finish client ... ");
link.Dispose();
ConsoleHelper.Header(true, "\n\n=== Press [Enter] to finish program ... ");
}
}
}
// ========================================================