Part II (closed) Flashcards

1
Q

How can EF react when adding multiple objects and an error occurs?

A

On saving changes EF detects that the bad insert item is not inserted and tries to add it once again and throws an error. A solution is to create a new dbcontect (brute force) or mark the bad item state as detached. In case of changed items (updated or deleted) state should be changed to unchanged.

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

How to you SaveChanges in EF in context of adding items?

A

When considering only a few inserts SaveChanges can be invoked after every insert, when bulk only once.

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

Why is maximum request length defined in ASP.NET?

A

To avoid DoS (Denial of Service) attack.

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

How is relationship many-to-many called when the joining table has additional data?

A

Many-to-many join with payload.

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

What is a database sharding?

A

A way of splitting databases and improving performance. Similar to horizontal partitioning but instances can exist independently (smaller tables are duplicated).

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

Horizontal partitioning vs vertical partitioning?

A

Horizontal is dividing data while vertical is dividing schema.

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

What is an N+1 problem?

A

A problem in which in a relationship 1-to-many (e.g. car and wheels) we want to get for a set of items all its children then N+1 queries can be generated, to avoid this we can load all children to memory and then join it. In EF it can be solved by eager loading using Include.

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

SOAP vs REST?

A

REST is simpler, without contract, should be controlled by HATEOAS, no backup for security, uses HTTP POST, GET, DEL, PUT, different formats

SOAP is heavier, it serves WS-Security, WS-ReliableMessaging, WS-AtomicTransaction, provides contract, uses HTTP POST, only XML

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

What is Liskov substitution principle?

A

That classes derived from abstractions should be used everywhere where abstraction without affecting application. For example Store, StandardMessageStore and RotatingStore which deletes some messages. Then getMessages won’t retrieve all messages.

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

Compare Inversion of Control, Dependency Inversion and Dependency Injection?

A

Inversion of control, inverts program flows because custom code is called by some framework, Dependency Injection helps IoC achieve this goal. Dependency Inversion is about references -> high level module and low level modules should depend on abstractions.

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

Compare Read Committed, Repeatable Read and Serializable?

A

RC ensures that all data is committed, future read can bring different results, RR guarantees that future reads will show exactly the same data while SR guarantees that no new data is inserted.

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

Main ways of structuring view model and model in ASP.NET MVC?

A

Inheritance, composition, duplication of code.

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

What’s the convention for naming partial views in ASP.NET?

A

To start with underscore _ and suffix with “Partial”

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

What data models are there in EF?

A

Conceptual, logical, physical.

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

Main approaches to data in EF?

A

Model-first (designer generates DB and domain classes), database-first (designer, generates domain classes), code-first (code, migrations).

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

What object hold all the information required to query database and map to entity objects and what are its main parts?

A

EDM (Entity Data Model) which is created in memory holds:

  • conceptual model: domain classes, context class, configuration
  • storage model: information about db schema
  • mappings: mapping between conceptual and storage
17
Q

What is the Object Service in EF?

A

A part of EF responsible for talking with database, especially materializing queries (converting query’s result to entity objects.

18
Q

What is Entity Client Data Provider in EF?

A

A part of EC responsible for transalting LINQ to Entities query or Entity Sql Query to SQL.

19
Q

What represents a session with the underlying database in EF?

A

DbContext

20
Q

What is an entity in EF, what are type of entity’s properties?

A

A class that can be used with DbSet and relates to single table in a database. Its properties reference columns of this table. There are two types of entities properties:

  • Scalar Property (single value, column)
  • Navigation Property:
    • Reference Property,
    • CollectionProperty
21
Q

What is a POCO class?

A

Plain Old CLR Object - a class that doesn’t contain any framework-specific elements, doesn’t derive from any specific base class.

22
Q

What are 2 types of entities in EF?

A

POCO, POCO Proxy (dynamic proxy) which enables lazy loading, but POCO class must fullfil some requirements .

23
Q

Which state conversion is handled automatically by EF context?

A

From Unchanged to Modified.

24
Q

What are persistence scenarios in EF?

A

Connected, disconnected

25
Q

What is OCC (Optimistic Concurrency Control)?

A

A way of maintaining concurrency in which there are no locks but each transaction does its work but before commiting it checks if another transaction made any changes. If yes it restarts itself and tries again. Good for low data contention systems. Pessimistic concurrency relates to locking methods.

26
Q

How to improve performance in EF while getting read-only properties?

A

Use AsNoTracking on DbSet.

27
Q

What kind of joining table is supported in EF without the need for creating additional model class and managing it?

A

Joining table without payload.

28
Q

How to retrieve in SQL number of rows affected by last statement?

A

Using @@ROWCOUNT

29
Q

Compare Data Driven Dev with Domain Driven Dev?

A

In DDD you should first create domain model without database. The best way is to create it without database, use TDD and create an application. Only then you should create a database but using the repository pattern to introduce abstraction.

In Data Driven Dev you first create your database and your model reflects that database and operations on it -> CRUD.