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.

A

query

17
Q

query expressed in query syntax

A

query expression

18
Q

what clause starts a query expression

A

from

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

A

True

24
Q

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

A

True

25
Q

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.

A

True

26
Q

any variable that stores a query instead of the result of a query.

A

query variable

27
Q

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.

A

True

28
Q

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.

A

True

29
Q

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.

A

True

30
Q

what are the ways to query using LINQ?

A

Query syntax and method syntax

31
Q

Used for retrieving data from the database

A

SELECT Statement

32
Q

The SELECT statement has several clauses:

A
Select 
From  
Where 
Group by 
Having 
Order by
33
Q

What is the logical order of operations to the SELECT statement

A

from, where, group by, having, select, order by

34
Q

Used to unnormalize 2 or more tables into one table, on a common column

A

JOIN

35
Q

What is an example syntax using JOIN?

A

SELECT * FROM Table_1 JOIN Table 2 ON Table_1.Id = Table_2.Table1Id

36
Q

what are the join types?

A

Inner (Default)
Full
Left
Right

37
Q

Combines rows from both the queries

A

UNION

38
Q

Keeps only those rows which are common in both queries

A

INTERSECT

39
Q

Keeps rows from the left query which are not included in the right query

A

MINUS