# using Dapper DB Multimapping Step 1 is done already you must proceed to step 2 See attached photo for the problem and instructions. All the instructions are there already

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C# using Dapper DB Multimapping

Step 1 is done already you must proceed to step 2

See attached photo for the problem and instructions. All the instructions are there already

STEP
1: DONE
1. Run SchoolDb.sql to your local database. It will create an Exer 3Db database with a School
Department Table.
College
Department
Id
Id
Name
Name
Address
Dean
Chair
Motto
Theme
Collegeld
Average Tuition
Schoolld
15
16
/*** Drop Table ***/
17 DROP TABLE IF EXISTS [dbo]. [School]
18
GO
/*** Drop Table ***/
19
DROP TABLE IF EXISTS [dbo].[College]
21
GO
22
/*** Drop Table ***/
23 DROP TABLE IF EXISTS [dbo]. [Department]
24
GO
25
26
/*** Create school table ***/
27 CREATE TABLE [dbo]. [School]
28
29
[ID] INT NOT NULL PRIMARY KEY IDENTITY(1,1),
30
[Name] NVARCHAR(50) NOT NULL,
31
[Address] NVARCHAR(50) NOT NULL,
32
[Motto] NVARCHAR(50) NOT NULL,
33
[Average Tuition] DECIMAL (18,2) NOT NULL
34
35
STEP 2: YOU MUST ADD/CREATE THE MODELS AND PROPERTIES
2. Add/create necessary models and properties for School, College, and Department models.
internal class School
F
{
// TODO: Fill with properties
/// <summary>
Add properties
/// Prints this object as JSON
/// </summary>
/// <returns>json string representation of this object</returns>
O references
public override string ToString()
{
return JsonConvert. SerializeObject(this);
STEP 3: Implement the functions below ASYNCHRONOUSLY
3. Implement ISchool Repository ASYNCHRONOUSLY.
o Get (id) - Returns single school with Id == id
o GetAll() - Returns all schools
o These methods should only use ONE sql statement and Query each call. NO MULTIPLE QUERY CALLS.
o Should utilize Dapper multimapping capabilities.
internal class School Repository : ISchool Repository
{
private DapperContext context;
O references
public School Repository ()
IMPLEMENT THIS ONE
_context = new DapperContext("Data Source=(localdb)\\P
public Task<IEnumerable<School>> GetAllSchools()
School
Id
Name
{
}
1 reference
{
}
throw new Not Implemented Exception();
1 reference
public Task<School> GetSchool(int id)
{
throw new Not Implemented Exception();
College, and
THIS
IS JUST A REFERENCE YOU CAN IGNORE THIS BUT
THIS ONE MIGHT HELP YOU SOLVING THE PROBLEM
Model format when printed in console
[
}
"Id": 1,
"Name" : "SchoolName1",
"Address" : "SchoolAddress1",
"Motto": "SchoolMotto1",
"AverageTuition": 1,
"Colleges" : [
{
]
}
"Id": 1,
"Name" : "CollegeName1",
"Dean" : "CollegeDean1",
"Theme" : "College Theme1",
"Departments":[
{
]
},
{
}
//
"Id": 1,
"Name": "DepartmentName1",
"Chair": "DepartmentChair1"
more schools
"Id": 2,
"Name": "DepartmentName2",
"Chair": "DepartmentChair2"
more departments under this collegel
more colleges under this school1
Transcribed Image Text:STEP 1: DONE 1. Run SchoolDb.sql to your local database. It will create an Exer 3Db database with a School Department Table. College Department Id Id Name Name Address Dean Chair Motto Theme Collegeld Average Tuition Schoolld 15 16 /*** Drop Table ***/ 17 DROP TABLE IF EXISTS [dbo]. [School] 18 GO /*** Drop Table ***/ 19 DROP TABLE IF EXISTS [dbo].[College] 21 GO 22 /*** Drop Table ***/ 23 DROP TABLE IF EXISTS [dbo]. [Department] 24 GO 25 26 /*** Create school table ***/ 27 CREATE TABLE [dbo]. [School] 28 29 [ID] INT NOT NULL PRIMARY KEY IDENTITY(1,1), 30 [Name] NVARCHAR(50) NOT NULL, 31 [Address] NVARCHAR(50) NOT NULL, 32 [Motto] NVARCHAR(50) NOT NULL, 33 [Average Tuition] DECIMAL (18,2) NOT NULL 34 35 STEP 2: YOU MUST ADD/CREATE THE MODELS AND PROPERTIES 2. Add/create necessary models and properties for School, College, and Department models. internal class School F { // TODO: Fill with properties /// <summary> Add properties /// Prints this object as JSON /// </summary> /// <returns>json string representation of this object</returns> O references public override string ToString() { return JsonConvert. SerializeObject(this); STEP 3: Implement the functions below ASYNCHRONOUSLY 3. Implement ISchool Repository ASYNCHRONOUSLY. o Get (id) - Returns single school with Id == id o GetAll() - Returns all schools o These methods should only use ONE sql statement and Query each call. NO MULTIPLE QUERY CALLS. o Should utilize Dapper multimapping capabilities. internal class School Repository : ISchool Repository { private DapperContext context; O references public School Repository () IMPLEMENT THIS ONE _context = new DapperContext("Data Source=(localdb)\\P public Task<IEnumerable<School>> GetAllSchools() School Id Name { } 1 reference { } throw new Not Implemented Exception(); 1 reference public Task<School> GetSchool(int id) { throw new Not Implemented Exception(); College, and THIS IS JUST A REFERENCE YOU CAN IGNORE THIS BUT THIS ONE MIGHT HELP YOU SOLVING THE PROBLEM Model format when printed in console [ } "Id": 1, "Name" : "SchoolName1", "Address" : "SchoolAddress1", "Motto": "SchoolMotto1", "AverageTuition": 1, "Colleges" : [ { ] } "Id": 1, "Name" : "CollegeName1", "Dean" : "CollegeDean1", "Theme" : "College Theme1", "Departments":[ { ] }, { } // "Id": 1, "Name": "DepartmentName1", "Chair": "DepartmentChair1" more schools "Id": 2, "Name": "DepartmentName2", "Chair": "DepartmentChair2" more departments under this collegel more colleges under this school1
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Embedded software development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education