Part III Flashcards

1
Q

How to turn off lazy loading for navigation property in EF?

A

By not making it virtual.

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

How to save changes to whole entity graph in EF?

A

Compare objects keys to default ones. If default then Context.Entry(object).State is Added else Modified.

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

How to improve performance of inserting, removing collections in EF?

A

By using DbSet.AddRange, InsertRange.

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

How to handle concurrency in EF with rowversion and DB-first?

A

Add new column of type rowversion (8 bytes incremented number for whole database). In EF diagram set properties of this column concurrency to fixed. Then all update will dheck it.

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

What’s the information expert principle?

A

It states that responsibility should be given to a class which contains all the information to handle it i.e. look at the classes and decide.

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

What are 2 main purposes of controller in GRASP?

A

To execute a system operation (adding user, adding item to cart), second is providing a layer between UI and domain models.

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

What flexibility give us the controller in GRASP?

A

We can change user interface without changing the logic - e.g. change web to terminal.

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

What are some points to favor composition over inhertiance?

A

Composition gives you runtime execution. Possible smaller number of classes.

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

What is indirection in GRASP?

A

A principle that states that interaction between objects is done via intermediate object to preserve low coupling (e.g. introducing Configuration class not providing config values directly in clients).

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

What’s the association, composition and aggregation? How to draw them in UML?

A

Association states that classes uses each other somehow. Composition is a relationship in which child cannot exist without parent (house and room), and in aggregation it can exist independently (car and engine). Composition - filled diamond (by parent), aggregation - empty diamond, association - straight line, may have arrows

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

What are the main parts of state pattern?

A

Context and state.

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

What is covariance?

A

Returning or assigning more derived types than declared.

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

What is contravariance?

A

Assinging or providing parameters of less generic types than declared.

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

What’s the difference between tier and layer?

A

Layer is logical, tier is physical.

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

What are the parts of 3-tier application?

A

Presentation, application and data.

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

What are main layers of application?

A

Presentation, application, business logic, data.

17
Q

Rules for lazy loading in EF?

A

In cofiguration: LazyLoadingEnable, ProxyCreationEnabled and particular property should be public virtual

18
Q

What’s the concurrency model in EF? How to handle it (example).

A

Optimistic concurrency. A row of type rowversion (timestamp) must be added to tables. It’s incremented each time an operation is done on a row. Then in database designer select this column and set concurrency as fixed. Only then exception about concurrency wil be thrown.

19
Q

How is .NET Core lifecycle different from .NET Framework?

A

.NET Core is also build using MsBuild. It is then executed by CoreCRL (on different OS-es) which uses JiT compiler. The process is hosted using dotnet.exe process (it hosts CoreCRL and code) .NET Core can also be prebuilt to native code using AoT.

20
Q

What is AoT?

A

Ahead of Time compiler which compiles (currently only UWP). Compiler is called .NET Native. It produces package of native code that is then executed by CoreCRL.

21
Q

How many CLR instances are there in Windows for .NET Framework?

A

Separate instance for each .NET process.

22
Q

How is Xamarin app built?

A

First MsBuild then Xamarin Compiler which generates IL for Android (dll, exe) which is then executed by Mono Runtime (similar to .NET Core). On IoS Xamarin Compiler generates native code using AOT (ARM language).

23
Q

How fody works?

A

It’s IL weaving. It has a MsBuild post build action which modified IL generated code.

24
Q

What is weaving? What types of weaving are there?

A

Weaving is adding some additional code to application. It can be done to a source code or to IL code.

25
Q

Is it possible to add own mechanism for insertion, deletion and update of entity in EF?

A

Yes, by using stored procedures. Create procedure for each CUD operation and then in diagram set that this entity operations are connected to those procedures. Then while modifying instances of the entity and saving changes those procedures will be invoked.

26
Q

What is DbEntityEntry used for?

A

It can be used for retrieving information about tracked entity. It contains information about changed values and current entity state. It also enables to set entity’s state.

27
Q

How is table-valued function different from stored procedure? What does it enable in EF?

A

It’s composable. In EF it enables to use table-valued function in Linq To Entities.

28
Q

How can you validate entities in EF?

A

You can override validation method in DbContext. Then e.g. while saving changes an error can occur due to this validation.

29
Q

How can you control transactions in EF? What’s the behavior of SaveChanges in such a situation?

A

By using BeginTransaction or UseTransaction. SaveChanges doesn’t immediately commit transactions,explicit call to transaction.Commit is required.

30
Q

How Just My Code works?

A

It looks for optimized assemblies or that without pdb files and steps over them while debugging.