amazing video. I do not understand how you tell the ef that AuthorsCollection has to be loaded in Book. If AuthorsCollection is internal (in domain project) and the repository is placed in an infrastructure project, it is impossible that Book DbSet reaches AuthorsCollection and includes them when GetBooks method from repository is called.
@zoran-horvat Жыл бұрын
Entity Framework is using reflection. It can even populate private members if needed, though you must specify non-public members with a string, rather than with a lambda.
@nickbarton31919 ай бұрын
@@zoran-horvatIt's been years since I've written a dB application and haven't used EF. So it uses reflection, that's awesome. I've watch many of your videos wondering how the data is materialised, now I know. But I dislike Blazer, once again MS have gone for interleaving HTML and code, so messy. This is no better than classic VB Web pages in this respect, written plenty of those. I much prefer markup like AngularJS. Maybe HTMX has the solution to this old problem.
@zoran-horvat9 ай бұрын
@@nickbarton3191 Blazor is just one of the implementations of WebAssembly, which is a separate standard defining a virtual machine and the corresponding byte code. It has little to do with Microsoft. Wasm can execute on any system, such as a browser or an embedded system, though it seems like only the browsers have accepted it so far.
@nickbarton31919 ай бұрын
@@zoran-horvat Ah OK, I'm out of touch with web programming.
@alexeycherepanov91508 ай бұрын
10:20 - why did you not sort list in AuthorsCollection's setter?
@zoran-horvat8 ай бұрын
Because it is populated by EF.
@alexeycherepanov91508 ай бұрын
10:20 there is easy way to do same - you can sort authors in setter of AuthorCollection property.
@zoran-horvat8 ай бұрын
That property is managed by EF.
@alexeycherepanov91508 ай бұрын
@@zoran-horvat and that is problem with it?? ef still need to call setter...
@zoran-horvat8 ай бұрын
@@alexeycherepanov9150 It is not the problem with that property. It is its purpose. How would you sort it anyway? It is an ICollection.
@alexeycherepanov91508 ай бұрын
@@zoran-horvat something like this: private ICollection _authorsCollection; internal ICollection AuthorsCollection { get => _authorsCollection; set => _authorsCollection = value.OrderBy(x=>x.Ordinal).ToArray(); }
@alexeycherepanov91508 ай бұрын
@@zoran-horvat something like this: private ICollection _authorsCollection; internal ICollection AuthorsCollection { get => _authorsCollection; set => _authorsCollection = value.OrderBy(x=>x.Ordinal).ToArray(); }
@superpcstation Жыл бұрын
Hi Zoran, doesn't the bool TryMoveAuthorUp(int index) functions breaks the command/query separation principle? Or is it something you don't worry about?
@zoran-horvat Жыл бұрын
Command/query separation principle has a corollary: it is common to return the command execution status in situations when querying for the same information after the command would look awkward, inefficient, needlessly complex or be outright impossible. A common case is when a command creates a child object and adds it to private structures that it also returns the newly created object, or at least a reference to it, like an ID, for the caller's bookkeeping (e.g. to add it to a DbContext, so that the child object will be persisted). However, it would be a violation of the principle if the command would return a result that would otherwise qualify as a query. The danger comes from some caller using such command in order to fetch its result, not knowing, or tolerating, the side effects caused by its action, which might not be appropriate in that situation.
@software_developer5 Жыл бұрын
I am working on a project, where we are using anemic design pattern throughout the project. We have anemic domain classes which are used everywhere and we have services to perform business logic, we are also using CQRS which then call these services so buniess logic divided between services and CQRS. Can you make a video or suggest how to move from anemic design model to rich domain in such cases
@zoran-horvat Жыл бұрын
I have plans for a series of videos dedicated to the gradual process of improving some typical deficiencies in the design, though I still don't have a timeline when I will start recording them. I also have a workshop ready, which I am holding in companies, titled Gradually Improving Software Design. If your managers are interested in organizing a training for your team, they can contact me directly for details.
@VoroninPavel Жыл бұрын
Once again. I hate EF Core for poor DDD support. All these code tricks with Lazy and alike are needed because navigation properties cannot be set through constructor. And there's no way to force EF to call some private method after entity is materialized. EF team does an excellent job and delivers many features, but in most cases those features are adding convenience for anemic models. ='(
@7th_CAV_Trooper8 ай бұрын
I agree. It's time for MSFT to rewrite EF with modern design principles in mind.
@TreeLuvBurdpu Жыл бұрын
They could still sort by last name.
@zoran-horvat Жыл бұрын
Yes, but that wouldn't make it the list of authors of a book.