сделал запрос объединения таблиц
This commit is contained in:
parent
5f3fdedbf6
commit
d21b4dde0d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
SportCompetitionsView/FormMain.Designer.cs
generated
13
SportCompetitionsView/FormMain.Designer.cs
generated
@ -36,6 +36,7 @@
|
||||
результатыToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonTest1 = new Button();
|
||||
button1 = new Button();
|
||||
buttonJoin = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -103,11 +104,22 @@
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += buttonTest2_Click;
|
||||
//
|
||||
// buttonJoin
|
||||
//
|
||||
buttonJoin.Location = new Point(174, 52);
|
||||
buttonJoin.Name = "buttonJoin";
|
||||
buttonJoin.Size = new Size(143, 39);
|
||||
buttonJoin.TabIndex = 6;
|
||||
buttonJoin.Text = "JOIN Member + Team";
|
||||
buttonJoin.UseVisualStyleBackColor = true;
|
||||
buttonJoin.Click += button_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 334);
|
||||
Controls.Add(buttonJoin);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonTest1);
|
||||
Controls.Add(menuStrip1);
|
||||
@ -129,5 +141,6 @@
|
||||
private ToolStripMenuItem результатыToolStripMenuItem;
|
||||
private Button buttonTest1;
|
||||
private Button button1;
|
||||
private Button buttonJoin;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using SportCompetitionsContracts.BindingModels;
|
||||
using SportCompetitionsContracts.BusinessLogicsContracts;
|
||||
using SportCompetitionsDatabaseImplement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -101,5 +102,48 @@ namespace SportCompetitionsView
|
||||
MessageBox.Show($"Âðåìÿ óäàëåíèÿ: {deletionTime}", "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
|
||||
private void button_Click(object sender, EventArgs e)
|
||||
{
|
||||
DateTime start = DateTime.Now; // Çàïèñûâàåì âðåìÿ íà÷àëà âûïîëíåíèÿ çàïðîñà
|
||||
|
||||
using (var db = new SportCompetitionsDatabase())
|
||||
{
|
||||
var query = from member in db.Members
|
||||
join team in db.Teams on member.TeamId + 1 equals team.Id
|
||||
select new
|
||||
{
|
||||
member.MemberFCs,
|
||||
member.MemberBirthDate,
|
||||
member.MemberGender,
|
||||
team.TeamName,
|
||||
team.TeamCountry
|
||||
};
|
||||
|
||||
var result = query.ToList();
|
||||
|
||||
DateTime stop = DateTime.Now; // Çàïèñûâàåì âðåìÿ çàâåðøåíèÿ âûïîëíåíèÿ çàïðîñà
|
||||
TimeSpan queryTime = stop - start; // Âû÷èñëÿåì âðåìÿ âûïîëíåíèÿ çàïðîñà
|
||||
|
||||
// Ñîçäàåì íîâóþ ôîðìó äëÿ îòîáðàæåíèÿ ðåçóëüòàòîâ
|
||||
var form = new Form();
|
||||
form.Width = 800;
|
||||
form.Height = 600;
|
||||
|
||||
// Ñîçäàåì DataGridView
|
||||
var dataGridView = new DataGridView();
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.AutoGenerateColumns = true;
|
||||
dataGridView.DataSource = result;
|
||||
|
||||
// Äîáàâëÿåì DataGridView íà ôîðìó
|
||||
form.Controls.Add(dataGridView);
|
||||
|
||||
// Îòîáðàæàåì ôîðìó
|
||||
form.ShowDialog();
|
||||
|
||||
// Âûâîäèì ñîîáùåíèå ñ çàìåðîì âðåìåíè âûïîëíåíèÿ çàïðîñà
|
||||
MessageBox.Show($"Âðåìÿ âûïîëíåíèÿ çàïðîñà: {queryTime.TotalMilliseconds} ìñ", "Âðåìÿ çàïðîñà", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user