Part II (closed) Flashcards
How can EF react when adding multiple objects and an error occurs?
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 to you SaveChanges in EF in context of adding items?
When considering only a few inserts SaveChanges can be invoked after every insert, when bulk only once.
Why is maximum request length defined in ASP.NET?
To avoid DoS (Denial of Service) attack.
How is relationship many-to-many called when the joining table has additional data?
Many-to-many join with payload.
What is a database sharding?
A way of splitting databases and improving performance. Similar to horizontal partitioning but instances can exist independently (smaller tables are duplicated).
Horizontal partitioning vs vertical partitioning?
Horizontal is dividing data while vertical is dividing schema.
What is an N+1 problem?
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.
SOAP vs REST?
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
What is Liskov substitution principle?
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.
Compare Inversion of Control, Dependency Inversion and Dependency Injection?
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.
Compare Read Committed, Repeatable Read and Serializable?
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.
Main ways of structuring view model and model in ASP.NET MVC?
Inheritance, composition, duplication of code.
What’s the convention for naming partial views in ASP.NET?
To start with underscore _ and suffix with “Partial”
What data models are there in EF?
Conceptual, logical, physical.
Main approaches to data in EF?
Model-first (designer generates DB and domain classes), database-first (designer, generates domain classes), code-first (code, migrations).