Skip Navigation Links.

Northwind\ConsoleNative\Program.cs

D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\ConsoleNative\Program.cs
/*
 * This file was generated by ProCG version 2.0
 *
 * File name:	Northwind\ConsoleNative\Program.cs
 * Language:	C# - ADO.Net 
 * Database:	My Sql
 *
 * Copyright (c) 2002-2019 iGenXSoft.
 * For more information visit http://www.igenxsoft.com
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using Northwind.Data;
using Microsoft.EntityFrameworkCore;
using MySql.Data.EntityFrameworkCore;
using MySql.Data.EntityFrameworkCore.Extensions;
using Newtonsoft.Json;

namespace ConsoleNative
{
	class Program
	{
		private DataManager datamanager;

		protected DataManager DataManager
		{
			get
			{
				if (datamanager == null)
					datamanager = new DataManager();
				return datamanager;
			}
		}

		static void Main(string[] args)
		{
			var program = new Program();

			//program.TestLogAndConfig();
			//program.TestJson();
			//program.CustomerActions();
			program.CodesActions();
			//program.GetDataFromDatabase();
			Console.ReadKey();
		}

		private void CustomerActions()
		{
			CCustomer customer = new CCustomer()
			{
				City = "Yad Binyamin",
				FirstName = "Zion",
				LastName = "Bokobza",
				Phone = "97258480600",
			};

			DataManager.Insert(customer);

		}

		private void TestJson()
		{

			var testTables = CTestTableCollection.GetFakeData(10);
			Console.WriteLine(testTables.ToInstnace());
			// single codes
			string text = JsonConvert.SerializeObject(testTables);
			var testTableBack = JsonConvert.DeserializeObject<CTestTableCollection>(text);
			var deserializedText = JsonConvert.SerializeObject(testTableBack);


		}

		private void CodesActions()
		{
			CCodesRecord codesRecord = DataManager.CodesRecord;
			var code1 = codesRecord.GetSingle(1, "5^2");
			var code2 = codesRecord.GetSingle(1, code1);
			var codeFromRecord = (CCodes)codesRecord.GetRecordData();
			codeFromRecord.TableNum = 5;
			codeFromRecord.CodeNum = 2;
			var code3 = codesRecord.GetSingle("Select * from Codes where TableNum =:Codes.TableNum and CodeNum = :Codes.CodeNum");

			var projectCodes = DataManager.CodesRecord.GetCodesTablesCollection();

			foreach (var code in projectCodes)
			{
				Console.WriteLine(code.ToInstnace());
			}
			DataManager.Dispose();
			datamanager = null;

		}

		private void GetDataFromDatabase()
		{
			var codes = DataManager.CodesRecord.GetCodesTablesCollection();
			List<CCodes> codesList = new List<CCodes>(codes);
			string text, deserializedText;
			CCodes code;
			CCodesCollection codesCollection;
			//CCodesEntity codesEntity;

			// single codes
			text = JsonConvert.SerializeObject(codes[0]);
			code = JsonConvert.DeserializeObject<CCodes>(text);
			deserializedText = JsonConvert.SerializeObject(code);

			// Collection
			text = JsonConvert.SerializeObject(codes);
			codesCollection = JsonConvert.DeserializeObject<CCodesCollection>(text);
			deserializedText = JsonConvert.SerializeObject(codesCollection);

			// Entity
			//codesEntity = DataManager.CodesRecord.GetSpeceficCode(1, -1, 5).GetEntity(true, true);
			//text = JsonConvert.SerializeObject(codesEntity);
			//CCodesEntity.AutomaticLoadingWhenReferencing = false;
			//CCodesEntity codesEntity2 = JsonConvert.DeserializeObject<CCodesEntity>(text);
			//deserializedText = JsonConvert.SerializeObject(codesEntity2);
			//CCodesEntity.AutomaticLoadingWhenReferencing = true; // as the default
		}

	}
}


  //      1696 ProCG uses this line - don't edit it