WorksheetsEF Core advanced
Total questions: 21
Worksheet time: 20mins
.Where(Func<int, int> predicate) is a signature of
IEnumerable
IQueryable
To provide lazy loading we need to mark navigation property as _____ and the entity should not be _____
(write two words separated by space)
(a)
TPH розшифровується як (a)
What can IEnumerable do?
LINQ-to-SQL
LINQ-to-Object
Can pass a compiled function to LINQ extensions
Can pass an expression tree to LINQ extensions
How Include() solves N+1 problem?
By running queries asynchronously
Using JOIN
By grouping big number of queries
What will be returned if LazyLoading is turned On and Off respectively ?
var countries = db.Countries.Take(3);
var capitals = new List<Capital>();
foreach(var country in countries)
{
capitals.Add(country.Capital.Name);
}
return capitals;
On (null reference exception) | Off (null reference exception)
On (null reference exception) | Off (returns list of Capital names)
On (returns list of Capital names) | Off (null reference exception)
On (returns list of Capital names) | Off (returns list of Capital names)
Which additional method(s) we can use in the explicit loading?
Collection()
LoadAll()
Reference()
Сhoose the correct statement(s) about TPH
An entire class hierarchy can be mapped to a single table
Every class and subclass including abstract classes has its own table
The table includes columns for all properties of all classes in the hierarchy
Representing inheritance relationships as relational foreign key associations
Which method should we use after [Include()] to continue including further levels of related data?
Include()
ThenInclude()
Select()
ThenSelect()
n+1 problem is caused by:
Too many joins in one query
Too many separate queries
_________ means that the related data is transparently loaded from the database when the navigation property is accessed.
Eager
Explicit
Lazy
It is a process to delay the loading of related objects until it is required.
Lazy Loading
Eager Loading
Explicit Loading
Використовуючи lazy loading, ви підвантажили всіх користувачів у контекст. У базі змінилися дані деяких користувачів.
Чи буде контекст використовувати оновлені дані?
Так
Ні
How many tables EF will create for all these classes?
class A { }
class B : A { }
class C : B { }
class D { }
class E : D { }
1
2
3
4
5
How many tables`ll be created, if EF core`s configuration is left to default ?
(write a number)
(a)
Expression<TDelegate> is compiled into a data structure called an expression (a) (if empty, enter '-').
Чи потрібно завжди використовувати Include() щоб отримати зв'язані дані?
Так
Ні
Fill in the gaps
(a)
Сhoose the correct statements:
IEnumerable is located in the System.Collections namespace
IQueryable inherits from ICollection
IQueryable doesn’t support lazy loading
IEnumerable represents a set of data in memory and can only move forward through this data.
Choose disadvantages of repository pattern:
It force programmer to work using the same pattern.
Encapsulates large database queries in methods
The number of classes is growing
Limits the use of the features of the ORM framework
Нехай ми маємо такий код.
Якщо list це IEnumerable то сигнатура методу Where буде такою: Where(Func<int, bool> predicate)
Якою буде сигнатура методу Where, якщо list це IQueryable
list.Where(x => x > 0);
(a)
