COMPSCI 335讲解、辅导SQL程序、讲解data留学生编程
- 首页 >> Python编程 COMPSCI 335 1 A#2.4
Assignment #2.4 – Chinook
Run a fluent dynamic query on the Chinook.db SQLite database.
The query comes from stdin, in the following format (sample):
Artists
OrderBy Name DESC
Where ArtistId % 10 == 0
Take 3
Select new (ArtistId, Name)
The first line contains the starting table.
Each of the next line contains the name of a LINQ operator, followed by a lambda given
in the string format expected by dynamic LINQ.
The project will translate the above input into the following dynamic LINQ code:
var seq2 = db.Artists
.OrderBy ("Name DESC")
.Where ("ArtistId % 10 == 0")
.Take (3)
.Select ("new (ArtistId, Name)");
FYI, this corresponds to the following standard LINQ code:
var seq2 = db.Artists
.OrderByDescending (id => Name)
.Where (id => id.ArtistId % 10 == 0)
.Take (3)
.Select (id => new {id.ArtistId, id.Name};
The dynamic LINQ result, which here is a dynamic queryable sequence, will be further
transformed and printed to stdout in JSON format:
var res = JsonSerializer.Serialize (seq2 .AsEnumerable () .ToList ());
COMPSCI 335 2 A#2.4
Pretty printed result:
[
{"ArtistId":150,"Name":"U2"},
{"ArtistId":70,"Name":"Toquinho \u0026 Vin\u00EDcius"},
{"ArtistId":200,"Name":"The Posies"}
]
Submission: to automarker, one single C# source file, containing your code and the
chinook EF scaffold (cf. the skeleton)
Additional packages:
o Microsoft.EntityFrameworkCore.Sqlite
o System.Linq.Dynamic.Core
Skelton folder contains:
o a C# project file, including the additional packages
o a C# source file, including the scaffold
o a copy of chinook.db
o sample requests and responses
o bat and sh script files
Tables: ….
Dynamic LINQ functions: Select, Where, OrderBy, Skip, Take
Assignment #2.4 – Chinook
Run a fluent dynamic query on the Chinook.db SQLite database.
The query comes from stdin, in the following format (sample):
Artists
OrderBy Name DESC
Where ArtistId % 10 == 0
Take 3
Select new (ArtistId, Name)
The first line contains the starting table.
Each of the next line contains the name of a LINQ operator, followed by a lambda given
in the string format expected by dynamic LINQ.
The project will translate the above input into the following dynamic LINQ code:
var seq2 = db.Artists
.OrderBy ("Name DESC")
.Where ("ArtistId % 10 == 0")
.Take (3)
.Select ("new (ArtistId, Name)");
FYI, this corresponds to the following standard LINQ code:
var seq2 = db.Artists
.OrderByDescending (id => Name)
.Where (id => id.ArtistId % 10 == 0)
.Take (3)
.Select (id => new {id.ArtistId, id.Name};
The dynamic LINQ result, which here is a dynamic queryable sequence, will be further
transformed and printed to stdout in JSON format:
var res = JsonSerializer.Serialize (seq2 .AsEnumerable () .ToList ());
COMPSCI 335 2 A#2.4
Pretty printed result:
[
{"ArtistId":150,"Name":"U2"},
{"ArtistId":70,"Name":"Toquinho \u0026 Vin\u00EDcius"},
{"ArtistId":200,"Name":"The Posies"}
]
Submission: to automarker, one single C# source file, containing your code and the
chinook EF scaffold (cf. the skeleton)
Additional packages:
o Microsoft.EntityFrameworkCore.Sqlite
o System.Linq.Dynamic.Core
Skelton folder contains:
o a C# project file, including the additional packages
o a C# source file, including the scaffold
o a copy of chinook.db
o sample requests and responses
o bat and sh script files
Tables: ….
Dynamic LINQ functions: Select, Where, OrderBy, Skip, Take