07.JSON-Processing-Exercises
07.JSON-Processing-Exercises
This document defines the exercise assignments for the Databases Advanced - Entity Framework course @ SoftUni
You can check your solutions in Judge
Users should have many Products sold and many Products bought.
Products should have many Categories.
Categories should have many Products.
CategoriesProducts should map Products and Categories.
1. Import Data
Query 1. Import Users
NOTE: You will need method public static string ImportUsers(ProductShopContext context,
string inputJson) and public StartUp class.
Import the users from the provided file "users.json".
Your method should return a string with the following message:
$"Successfully imported {users.Count}";
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
2. Export Data
Write the below-described queries and export the returned data to the specified format. Make sure that Entity
Framework Core generates only a single query for each task.
Note that because of the random generation of the data, the output probably will be different.
products-in-range.json
[
{
"name": "TRAMADOL HYDROCHLORIDE",
"price": 516.48,
"seller": " Thompson"
},
{
"name": "Allopurinol",
"price": 518.50,
"seller": "Jacqueline Perez"
},
{
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
users-sold-products.json
[
{
"firstName": "Gloria",
"lastName": "Alexander",
"soldProducts": [
{
"name": " Metoprolol Tartrate",
"price": 1405.74,
"buyerFirstName": "Bonnie",
"buyerLastName": "Fox"
}
]
},
...
]
categories-by-products.json
[
{
"category": "Garden",
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
users-and-products.json
{
"usersCount": 54,
"users": [
{
"lastName": "Stewart",
"age": 39,
"soldProducts":
{
"count": 9,
"products":
[
{
"name": "Finasteride",
"price": 1374.01
},
{
"name": "Glyburide",
"price": 95.10
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
Car Dealer
1. Setup Database
A car dealer needs information about cars, their parts, parts suppliers, customers and sales.
Cars have Make, Model, TraveledDistance in kilometers.
Parts have Name, Price and Quantity.
Supplier has a Name and info whether they supply imported parts.
Customer has a Name, BirthDate and info whether they are a young driver (young driver is a driver
that has less than 2 years of experience. Those customers get an additional 5% off for the sale.).
Sale has a Car, Customer and a Discount percentage.
A Price of a Car is formed by the total price of its Parts.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
2. Import Data
Import data from the provided files ("suppliers.json", "parts.json", "cars.json",
"customers.json")
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
3. Export Data
Write the below described queries and export the returned data to the specified format. Make sure that Entity
Framework Core generates only a single query for each task.
ordered-customers.json
[
{
"Name": "Louann Holzworth",
"BirthDate": " 01/10/1960",
"IsYoungDriver": false
},
{
"Name": "Donnetta Soliz",
"BirthDate": "01/10/1963",
"IsYoungDriver": true
},
...
]
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
toyota-cars.json
[
{
"Id": 134,
"Make": "Toyota",
"Model": "Camry Hybrid",
"TraveledDistance": 486872832,
},
{
"Id": 139,
"Make": "Toyota",
"Model": "Camry Hybrid",
"TraveledDistance": 397831570,
},
...
]
local-suppliers.json
[
{
"Id": 2,
"Name": "Agway Inc.",
"PartsCount": 3
},
{
"Id": 4,
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
cars-and-parts.json
[
{
"car": {
"Make": "Opel",
"Model": "Omega",
"TraveledDistance": 176664996
},
"parts": [
{
"Name": "Rear Right Side Inner door handle",
"Price": "79.99"
},
{
"Name": "Door water-shield",
"Price": "123.99"
},
{
"Name": "Front Right Side Door Glass",
"Price": "100.91"
},
{
"Name": "Window motor",
"Price": "123.49"
},
{
"Name": "Rocker arm",
"Price": "98.99"
},
{
"Name": "Turbocharger",
"Price": "0.40"
},
{
"Name": "Water pipe",
"Price": "44.94"
},
{
"Name": "Muffler",
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
customers-total-sales.json
[
{
"fullName": " Faustina Burgher",
"boughtCars": 4,
"spentMoney": 12585.89
},
{
"fullName": " Garret Capron",
"boughtCars": 3,
"spentMoney": 11743.59
},
{
"fullName": " Carri Knapik",
"boughtCars": 4,
"spentMoney": 11550.63
},
...
]
sales-discounts.json
[
{
"car": {
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.
© SoftUni – https://softuni.org. Copyrighted document. Unauthorized copy, reproduction or use is not permitted.