diff --git a/TransportCompany/TransportCompany/FormCheckTimeJoin.Designer.cs b/TransportCompany/TransportCompany/FormCheckTimeJoin.Designer.cs
new file mode 100644
index 0000000..6ee4659
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCheckTimeJoin.Designer.cs
@@ -0,0 +1,135 @@
+namespace TransportCompany
+{
+ partial class FormCheckTimeJoin
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ textBoxFirstCheck = new TextBox();
+ groupBoxFirst = new GroupBox();
+ buttonCheckFirstJoin = new Button();
+ groupBoxSecond = new GroupBox();
+ textBoxSecondCheck = new TextBox();
+ buttonCheckSecondJoin = new Button();
+ buttonCancel = new Button();
+ groupBoxFirst.SuspendLayout();
+ groupBoxSecond.SuspendLayout();
+ SuspendLayout();
+ //
+ // textBoxFirstCheck
+ //
+ textBoxFirstCheck.Location = new Point(312, 42);
+ textBoxFirstCheck.Name = "textBoxFirstCheck";
+ textBoxFirstCheck.Size = new Size(228, 27);
+ textBoxFirstCheck.TabIndex = 0;
+ //
+ // groupBoxFirst
+ //
+ groupBoxFirst.Controls.Add(buttonCheckFirstJoin);
+ groupBoxFirst.Controls.Add(textBoxFirstCheck);
+ groupBoxFirst.Location = new Point(12, 12);
+ groupBoxFirst.Name = "groupBoxFirst";
+ groupBoxFirst.Size = new Size(580, 91);
+ groupBoxFirst.TabIndex = 1;
+ groupBoxFirst.TabStop = false;
+ groupBoxFirst.Text = "Для первого запроса";
+ //
+ // buttonCheckFirstJoin
+ //
+ buttonCheckFirstJoin.Location = new Point(65, 42);
+ buttonCheckFirstJoin.Name = "buttonCheckFirstJoin";
+ buttonCheckFirstJoin.Size = new Size(195, 29);
+ buttonCheckFirstJoin.TabIndex = 1;
+ buttonCheckFirstJoin.Text = "Произвести замер";
+ buttonCheckFirstJoin.UseVisualStyleBackColor = true;
+ buttonCheckFirstJoin.Click += ButtonCheckFirstJoin_Click;
+ //
+ // groupBoxSecond
+ //
+ groupBoxSecond.Controls.Add(textBoxSecondCheck);
+ groupBoxSecond.Controls.Add(buttonCheckSecondJoin);
+ groupBoxSecond.Location = new Point(12, 109);
+ groupBoxSecond.Name = "groupBoxSecond";
+ groupBoxSecond.Size = new Size(580, 95);
+ groupBoxSecond.TabIndex = 2;
+ groupBoxSecond.TabStop = false;
+ groupBoxSecond.Text = "Для второго запроса";
+ //
+ // textBoxSecondCheck
+ //
+ textBoxSecondCheck.Location = new Point(312, 41);
+ textBoxSecondCheck.Name = "textBoxSecondCheck";
+ textBoxSecondCheck.Size = new Size(228, 27);
+ textBoxSecondCheck.TabIndex = 1;
+ //
+ // buttonCheckSecondJoin
+ //
+ buttonCheckSecondJoin.Location = new Point(65, 41);
+ buttonCheckSecondJoin.Name = "buttonCheckSecondJoin";
+ buttonCheckSecondJoin.Size = new Size(195, 29);
+ buttonCheckSecondJoin.TabIndex = 0;
+ buttonCheckSecondJoin.Text = "Произвести замер";
+ buttonCheckSecondJoin.UseVisualStyleBackColor = true;
+ buttonCheckSecondJoin.Click += ButtonCheckSecondJoin_Click;
+ //
+ // buttonCancel
+ //
+ buttonCancel.Location = new Point(452, 220);
+ buttonCancel.Name = "buttonCancel";
+ buttonCancel.Size = new Size(140, 29);
+ buttonCancel.TabIndex = 3;
+ buttonCancel.Text = "Закрыть";
+ buttonCancel.UseVisualStyleBackColor = true;
+ buttonCancel.Click += ButtonCancel_Click;
+ //
+ // FormCheckTimeJoin
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(604, 259);
+ Controls.Add(buttonCancel);
+ Controls.Add(groupBoxSecond);
+ Controls.Add(groupBoxFirst);
+ Name = "FormCheckTimeJoin";
+ Text = "Замер времени сложных запросов";
+ groupBoxFirst.ResumeLayout(false);
+ groupBoxFirst.PerformLayout();
+ groupBoxSecond.ResumeLayout(false);
+ groupBoxSecond.PerformLayout();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private TextBox textBoxFirstCheck;
+ private GroupBox groupBoxFirst;
+ private Button buttonCheckFirstJoin;
+ private GroupBox groupBoxSecond;
+ private TextBox textBoxSecondCheck;
+ private Button buttonCheckSecondJoin;
+ private Button buttonCancel;
+ }
+}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormCheckTimeJoin.cs b/TransportCompany/TransportCompany/FormCheckTimeJoin.cs
new file mode 100644
index 0000000..2798145
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCheckTimeJoin.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using TransportCompanyContracts.BusinessLogicsContracts;
+
+namespace TransportCompany
+{
+ public partial class FormCheckTimeJoin : Form
+ {
+ private readonly ITruckingLogic _truckingLogic;
+
+ private readonly IClientLogic _clientLogic;
+
+ public FormCheckTimeJoin(ITruckingLogic truckingLogic, IClientLogic clientLogic)
+ {
+ InitializeComponent();
+
+ _truckingLogic = truckingLogic;
+ _clientLogic = clientLogic;
+ }
+
+ private void ButtonCheckFirstJoin_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ textBoxFirstCheck.Text = _truckingLogic.TestFirstJoin();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCheckSecondJoin_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ textBoxSecondCheck.Text = _clientLogic.TestSecondJoin();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/TransportCompany/TransportCompany/FormCheckTimeJoin.resx b/TransportCompany/TransportCompany/FormCheckTimeJoin.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/TransportCompany/TransportCompany/FormCheckTimeJoin.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTrucking.Designer.cs b/TransportCompany/TransportCompany/FormTrucking.Designer.cs
index 9d4abca..35a895b 100644
--- a/TransportCompany/TransportCompany/FormTrucking.Designer.cs
+++ b/TransportCompany/TransportCompany/FormTrucking.Designer.cs
@@ -39,12 +39,13 @@
rndGenerationToolStripMenuItem = new ToolStripMenuItem();
generationClientsToolStripMenuItem = new ToolStripMenuItem();
generationTruckingsToolStripMenuItem = new ToolStripMenuItem();
+ testTimeGetDataToolStripMenuItem = new ToolStripMenuItem();
buttonUpdate = new Button();
comboBoxEmails = new ComboBox();
label1 = new Label();
checkBoxSorted = new CheckBox();
checkBoxForFilterMode = new CheckBox();
- testTimeGetDataToolStripMenuItem = new ToolStripMenuItem();
+ testComplexQueriesToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
@@ -72,7 +73,7 @@
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
- menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, rndGenerationToolStripMenuItem, testTimeGetDataToolStripMenuItem });
+ menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, rndGenerationToolStripMenuItem, testTimeGetDataToolStripMenuItem, testComplexQueriesToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(6, 3, 0, 3);
@@ -136,6 +137,13 @@
generationTruckingsToolStripMenuItem.Text = "Генерация перевозок";
generationTruckingsToolStripMenuItem.Click += GenerationTruckingsToolStripMenuItem_Click;
//
+ // testTimeGetDataToolStripMenuItem
+ //
+ testTimeGetDataToolStripMenuItem.Name = "testTimeGetDataToolStripMenuItem";
+ testTimeGetDataToolStripMenuItem.Size = new Size(227, 24);
+ testTimeGetDataToolStripMenuItem.Text = "Тест скорости чтения данных";
+ testTimeGetDataToolStripMenuItem.Click += TestTimeGetDataToolStripMenuItem_Click;
+ //
// buttonUpdate
//
buttonUpdate.Location = new Point(1014, 138);
@@ -185,12 +193,12 @@
checkBoxForFilterMode.Text = "Включить режим фильтра";
checkBoxForFilterMode.UseVisualStyleBackColor = true;
//
- // testTimeGetDataToolStripMenuItem
+ // testComplexQueriesToolStripMenuItem
//
- testTimeGetDataToolStripMenuItem.Name = "testTimeGetDataToolStripMenuItem";
- testTimeGetDataToolStripMenuItem.Size = new Size(227, 24);
- testTimeGetDataToolStripMenuItem.Text = "Тест скорости чтения данных";
- testTimeGetDataToolStripMenuItem.Click += TestTimeGetDataToolStripMenuItem_Click;
+ testComplexQueriesToolStripMenuItem.Name = "testComplexQueriesToolStripMenuItem";
+ testComplexQueriesToolStripMenuItem.Size = new Size(188, 24);
+ testComplexQueriesToolStripMenuItem.Text = "Тест сложных запросов";
+ testComplexQueriesToolStripMenuItem.Click += TestComplexQueriesToolStripMenuItem_Click;
//
// FormTrucking
//
@@ -248,5 +256,6 @@
private CheckBox checkBoxSorted;
private CheckBox checkBoxForFilterMode;
private ToolStripMenuItem testTimeGetDataToolStripMenuItem;
+ private ToolStripMenuItem testComplexQueriesToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/FormTrucking.cs b/TransportCompany/TransportCompany/FormTrucking.cs
index 72f7a75..e0855fc 100644
--- a/TransportCompany/TransportCompany/FormTrucking.cs
+++ b/TransportCompany/TransportCompany/FormTrucking.cs
@@ -176,5 +176,16 @@ namespace TransportCompany
LoadData();
}
}
+
+ private void TestComplexQueriesToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCheckTimeJoin));
+
+ if (service is FormCheckTimeJoin form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompany/Program.cs b/TransportCompany/TransportCompany/Program.cs
index 47e8b58..fcba0f4 100644
--- a/TransportCompany/TransportCompany/Program.cs
+++ b/TransportCompany/TransportCompany/Program.cs
@@ -62,6 +62,7 @@ namespace TransportCompany
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs
index 6e97b4d..5255dbc 100644
--- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs
+++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/ClientLogic.cs
@@ -80,12 +80,18 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
return true;
}
-
+ //для замера времени рандомного добавления
public string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email)
{
return _clientStorage.TestRandomInsert(count, _name, _surname, _patronymic, _telephone, _email);
}
+ //для проверки времени выполнения сложного запроса
+ public string TestSecondJoin()
+ {
+ return _clientStorage.SecondJoin();
+ }
+
public bool Update(ClientBindingModel model)
{
CheckModel(model);
@@ -99,7 +105,7 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
return true;
}
- public bool Delete(ClientBindingModel model)
+ public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
diff --git a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs
index e5e47e9..de7b905 100644
--- a/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs
+++ b/TransportCompany/TransportCompanyBusinessLogic/BusinessLogic/TruckingLogic.cs
@@ -92,6 +92,12 @@ namespace TransportCompanyBusinessLogic.BusinessLogic
return _truckingStorage.TestRandomInsert(count, clients, cargos, transports, transportations);
}
+ //первый сложный запрос
+ public string? TestFirstJoin()
+ {
+ return _truckingStorage.FirstJoin();
+ }
+
public bool Update(TruckingBindingModel model)
{
CheckModel(model);
diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs
index 95dfb66..8f318c6 100644
--- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs
+++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/IClientLogic.cs
@@ -19,6 +19,8 @@ namespace TransportCompanyContracts.BusinessLogicsContracts
string TestRandomCreate(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
+ string TestSecondJoin();
+
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
diff --git a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs
index ab74567..5fd7d83 100644
--- a/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs
+++ b/TransportCompany/TransportCompanyContracts/BusinessLogicsContracts/ITruckingLogic.cs
@@ -15,6 +15,8 @@ namespace TransportCompanyContracts.BusinessLogicsContracts
string? TestReadList();
+ string? TestFirstJoin();
+
TruckingViewModel? ReadElement(TruckingSearchModel model);
bool Create(TruckingBindingModel model);
diff --git a/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs b/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs
index 46bc3b4..d7b6f36 100644
--- a/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs
+++ b/TransportCompany/TransportCompanyContracts/StoragesContracts/IClientStorage.cs
@@ -21,6 +21,8 @@ namespace TransportCompanyContracts.StoragesContracts
string TestRandomInsert(int count, string[] _name, string[] _surname, string[] _patronymic, string[] _telephone, string[] _email);
+ string SecondJoin();
+
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
diff --git a/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs b/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs
index 6409ff9..97b0ef0 100644
--- a/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs
+++ b/TransportCompany/TransportCompanyContracts/StoragesContracts/ITruckingStorage.cs
@@ -15,6 +15,8 @@ namespace TransportCompanyContracts.StoragesContracts
string TestGetFullList();
+ string FirstJoin();
+
List GetFilteredList(TruckingSearchModel model);
TruckingViewModel? GetElement(TruckingSearchModel model);
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs
index 73837fa..c445c20 100644
--- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/ClientStorage.cs
@@ -111,6 +111,46 @@ namespace TransportCompanyDatabaseImplements.Implements
return stopwatch.ElapsedMilliseconds.ToString();
}
+
+ public string SecondJoin()
+ {
+ using var context = new ElegevContext();
+
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+
+ //старт замера времени добавления в бд
+ Stopwatch stopwatch = new();
+
+ stopwatch.Start();
+
+ var secondJoin = from t in context.Set()
+ from c in context.Set().Where(c => c.Id == t.ClientId)
+ select new { c, t };
+
+ //ВСЁ ГОТОВО ДЛЯ СЛЕДУЮЩЕГО ЗАМЕРА
+
+ foreach (var element in secondJoin)
+ {
+ element.t.Update(new TruckingBindingModel
+ {
+ Id = element.t.Id,
+ ClientId = element.t.ClientId,
+ CargoId = element.t.CargoId,
+ Price = element.t.Price,
+ DateStart = element.t.DateStart.AddDays(-10),
+ DateEnd = element.t.DateEnd.AddDays(-10),
+ TransportationId = element.t.TransportationId,
+ TransportId = element.t.TransportId,
+ });
+ }
+
+ context.SaveChanges();
+
+ stopwatch.Stop();
+
+ return stopwatch.ElapsedMilliseconds.ToString();
+ }
+
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new ElegevContext();
diff --git a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
index 3ba48fe..bc282b6 100644
--- a/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
+++ b/TransportCompany/TransportCompanyDatabaseImplements/Implements/TruckingStorage.cs
@@ -198,5 +198,46 @@ namespace TransportCompanyDatabaseImplements.Implements
throw;
}
}
+
+ //первый сложный запрос
+ public string FirstJoin()
+ {
+ using var context = new ElegevContext();
+
+ Random rnd = new Random(DateTime.Now.ToString().GetHashCode());
+
+ //старт замера времени добавления в бд
+ Stopwatch stopwatch = new();
+
+ stopwatch.Start();
+
+ var firstJoin = from t in context.Set().Where(t => t.Price == 1200000.0)
+ from c in context.Set().Where(c => c.Id == t.ClientId)
+ select new { t, c };
+
+ //ВСЁ ГОТОВО ДЛЯ СЛЕДУЮЩЕГО ЗАМЕРА
+ // 999999.0
+
+ foreach (var element in firstJoin)
+ {
+ element.t.Update(new TruckingBindingModel
+ {
+ Id = element.t.Id,
+ ClientId = element.t.ClientId,
+ CargoId = element.t.CargoId,
+ Price = 999999.0,
+ DateStart = element.t.DateStart,
+ DateEnd = element.t.DateEnd,
+ TransportationId = element.t.TransportationId,
+ TransportId = element.t.TransportId,
+ });
+ }
+
+ context.SaveChanges();
+
+ stopwatch.Stop();
+
+ return stopwatch.ElapsedMilliseconds.ToString();
+ }
}
}