Beispiel #1
0
        private static void TrySimpleQuery()
        {
            using (var db = new  EntityFrameworkCore(Config.ConnectionStrings.SqlConnection))
            {
                var _keys = from D in db.Data join
                            K in db.Keys on D.Id equals K.MyDataId
                            where D.Id == 2
                            select new
                {
                    D.Id,
                    MyDataId = K.Id,
                    K.Current,
                    K.Department,
                    D.Name
                };

                Console.WriteLine($"Keys Count = {_keys.Count()}");
                _keys.ForEachAsync(k => {
                    Console.WriteLine($@"Data: 
                                         ID={k.Id}, 
                                         Key={k.MyDataId}, 
                                         Department={k.Department}, 
                                         Name={k.Name},
                                         Date={k.Current:MM-dd-yyyy}, 
                                         Time={k.Current:HH:mm:ss}");
                }).Wait();
            }
        }
Beispiel #2
0
        private static void TryRelationshipQuery()
        {
            using (var db = new  EntityFrameworkCore(Config.ConnectionStrings.SqlConnection))
            {
                var _data = db.Data.Where(d => d.Id >= 3).Include("Keys");
                _data.ForEachAsync(d => {
                    Console.WriteLine("Count of Keys = " + d.Keys.Count);
                    Console.WriteLine($@"For - {d.Name}, Lets Put down Departments");

                    d.Keys.ForEach(k => { Console.WriteLine($@"Department: {k.Department} Created on {k.Current}"); });
                }).Wait();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            char input;

            do
            {
                ShowMenu();

                input = Console.ReadLine().First();
                switch (input)
                {
                case 'Q':
                    break;

                case 'T':
                    List <TestResult> testResults = new List <TestResult>();

                    Console.WriteLine("# of Test Runs:");
                    NumRuns = int.Parse(Console.ReadLine());

                    //Gather Details for Test
                    Console.WriteLine("# of Sports per Run: ");
                    NumSports = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Teams per Sport: ");
                    NumTeams = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Players per Team: ");
                    NumPlayers = int.Parse(Console.ReadLine());


                    List <SportDTO>  sports  = TestData.Generator.GenerateSports(NumSports);
                    List <TeamDTO>   teams   = new List <TeamDTO>();
                    List <PlayerDTO> players = new List <PlayerDTO>();
                    foreach (var sport in sports)
                    {
                        var newTeams = TestData.Generator.GenerateTeams(sport.Id, NumTeams);
                        teams.AddRange(newTeams);
                        foreach (var team in newTeams)
                        {
                            var newPlayers = TestData.Generator.GeneratePlayers(team.Id, NumPlayers);
                            players.AddRange(newPlayers);
                        }
                    }

                    Database.Reset();
                    Database.Load(sports, teams, players);

                    for (int i = 0; i < NumRuns + 1; i++)
                    {
                        if (i == 0)
                        {    //Discard first runs
                            DataAccess.Dapper firstDapperTest = new DataAccess.Dapper();
                            testResults.AddRange(RunTests(i, Framework.Dapper, firstDapperTest));

                            EntityFrameworkCoreWithTracking trackingTest = new EntityFrameworkCoreWithTracking();
                            testResults.AddRange(RunTests(i, Framework.EntityFrameworkCoreWithTracking, trackingTest));

                            EntityFrameworkCore efCoreTest = new EntityFrameworkCore();
                            testResults.AddRange(RunTests(i, Framework.EntityFrameworkCore, efCoreTest));
                            testResults.Clear();
                        }
                        else      //Run real tests
                        {
                            DataAccess.Dapper dapperTest = new DataAccess.Dapper();
                            testResults.AddRange(RunTests(i, Framework.Dapper, dapperTest));

                            EntityFrameworkCoreWithTracking trackingTest = new EntityFrameworkCoreWithTracking();
                            testResults.AddRange(RunTests(i, Framework.EntityFrameworkCoreWithTracking, trackingTest));

                            EntityFrameworkCore efCoreTest = new EntityFrameworkCore();
                            testResults.AddRange(RunTests(i, Framework.EntityFrameworkCore, efCoreTest));
                        }
                    }
                    ProcessResults(testResults);

                    break;
                }
            }while (input != 'Q');
        }
        static void Main(string[] args)
        {
            char input;

            do
            {
                ShowMenu();

                input = Console.ReadLine().First();
                switch (input)
                {
                case 'Q':
                    break;

                case 'T':
                    List <TestResult> testResults = new List <TestResult>();

                    Console.WriteLine("# of Test Runs:");
                    NumRuns = int.Parse(Console.ReadLine());

                    //Gather Details for Test
                    Console.WriteLine("# of Sports per Run: ");
                    NumSports = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Teams per Sport: ");
                    NumTeams = int.Parse(Console.ReadLine());

                    Console.WriteLine("# of Players per Team: ");
                    NumPlayers = int.Parse(Console.ReadLine());


                    List <SportDTO>  sports  = TestData.Generator.GenerateSports(NumSports);
                    List <TeamDTO>   teams   = new List <TeamDTO>();
                    List <PlayerDTO> players = new List <PlayerDTO>();
                    foreach (var sport in sports)
                    {
                        var newTeams = TestData.Generator.GenerateTeams(sport.Id, NumTeams);
                        teams.AddRange(newTeams);
                        foreach (var team in newTeams)
                        {
                            var newPlayers = TestData.Generator.GeneratePlayers(team.Id, NumPlayers);
                            players.AddRange(newPlayers);
                        }
                    }

                    Database.Reset();
                    Database.Load(sports, teams, players);

                    for (int i = 0; i < NumRuns; i++)
                    {
                        EntityFrameworkCore efCoreTest = new EntityFrameworkCore();
                        testResults.AddRange(RunTests(i, Framework.EntityFrameworkCore, efCoreTest));

                        ADONET adoTest = new ADONET();
                        testResults.AddRange(RunTests(i, Framework.ADONET, adoTest));

                        //ADONetReader adoReaderTest = new ADONetReader();
                        //testResults.AddRange(RunTests(i, Framework.ADONetDr, adoReaderTest));
                    }
                    ProcessResults(testResults);

                    break;
                }
            }while (input != 'Q');
        }