ORM/LINQ/SQL syntax Flashcards

1
Q

What is ORM?

A

Object Relational Mapper

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what do ORMs do?

A

ORMs maps data from DB to an object in your program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are the two ways to connect your database to your code?

A

DB first and Code first

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is DB first?

A

The DB structure already exists, classes are created based on the existing structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is code first?

A

You create the DB structure based on the classes in the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A _____ instance represents a session with the database and can be used to query and save instances of your entities

A

DBContext

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Used to connect to your db

A

Connection String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The project that you build and run

A

Startup project

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the syntax to create a migrations folder

A

dotnet ef migrations add -c –startup-project

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

a snapshot of the database schema given the current state of your models

A

Migration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the syntax to apply the changes of the latest migration to your database

A

dotnet ef database update

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does LINQ stand for?

A

Language-Integrated Query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

a uniform query syntax in C# and VB.NET to retrieve data from different sources and formats. It is integrated in C# or VB, thereby eliminating the mismatch between programming languages and databases, as well as providing a single querying interface for different types of data sources.

A

LINQ

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

3 parts of a query operation:

A

Data Source
Query
Execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Expressions that retrieve data from a data source

A

LINQ Queries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

a set of instructions that describes what data to retrieve from a given data source (or sources) and what type and organization the returned data should have.

17
Q

query expressed in query syntax

A

query expression

18
Q

what clause starts a query expression

19
Q

what clause ends a query expression

A

select or group

20
Q

how many clauses can be in a query expression

A

one or more

21
Q

what are some clauses?

A

where, orderby, join, let

22
Q

what does the INTO keyword in a query expression do?

A

enable the result of a join or group clause to serve as the source for additional query clauses in the same query expression

23
Q

From an application’s viewpoint, the specific type and structure of the original source data is not important

24
Q

The application always sees the source data as an IEnumerable or IQueryable collection.

25
A query can: 1. Retrieve a subset of the elements to produce a new sequence without modifying the individual elements. The query may then sort or group the returned sequence in various ways 2. Retrieve a sequence of elements but transform them to a new type of object. 3. Retrieve a singleton value about the source data, such as: The number of elements that match a certain condition. The element that has the greatest or least value. The first element that matches a condition, or the sum of values in a specified set of elements.
True
26
any variable that stores a query instead of the result of a query.
query variable
27
A query variable is always an enumerable type that will produce a sequence of elements when it is iterated over in a foreach statement or a direct call to its IEnumerator.MoveNext method.
True
28
By default, linq queries have deferred execution. This means that unless iterated via a foreach loop, the query isn’t going to retrieve data from the data source.
True
29
You can force immediate execution by either using an aggregate function in the query such as count or by calling the ToList() or ToArray() methods.
True
30
what are the ways to query using LINQ?
Query syntax and method syntax
31
Used for retrieving data from the database
SELECT Statement
32
The SELECT statement has several clauses:
``` Select From Where Group by Having Order by ```
33
What is the logical order of operations to the SELECT statement
from, where, group by, having, select, order by
34
Used to unnormalize 2 or more tables into one table, on a common column
JOIN
35
What is an example syntax using JOIN?
SELECT * FROM Table_1 JOIN Table 2 ON Table_1.Id = Table_2.Table1Id
36
what are the join types?
Inner (Default) Full Left Right
37
Combines rows from both the queries
UNION
38
Keeps only those rows which are common in both queries
INTERSECT
39
Keeps rows from the left query which are not included in the right query
MINUS