Pendramon
Pendramon
CC#
Created by tajgel on 1/7/2023 in #help
❔ Buttons xaml
stare
189 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
The learning path never ends, but we get closer and closer each time
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
I too have a lot to learn. I just scrapped my whole project cause of bad database modeling and some of the things I posted here 😄
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
Of course!
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
Its like a scale, on one part is design patterns on the other part is the size of your application. There is no point in doing all this if your application just does 2-3 simple data operations.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
But how far deep you should go depends on the size of your application.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
The bad thing about this is that you then automatically can't use most of the WebAPI niceties like filters, middleware, etc.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
There is this idea that Service layer should be agnostic to the top level project using it. So if you were to use a console app for example instead of a web api, it should respond the same way to the same requests.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
Or perhaps you do some manipulation of that data in the service layer and need to show a different result to the web api.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
No, specifically because Entities may contain some data that the Web API should not know about.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
From my recently learned experience, yes. I hate having so many layers of DTOs but unfortunately it seems like it has to be done.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
If you have any questions about any of this feel free to ask
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
Another thing that has been pointed out to me is that you should have another set of DTOs in Web API project. The reason being is that Web Api endpoints shouldn't change so you don't break consumers of the web api. If you change a service layer dto it will also change the web api endpoint(for example if you remove some property from the service layer dto). Another reason is, If all of your endpoint parameters don't come from body, you will need a separate dto for the from body parameter which then inside your endpoint method you would combine the data from the query parameters and the from body dto parameter to a service layer dto. One more thing I've learned is to always use a DTO for your FromBody parameter. If you use a single value type then the web api request body would be just the value for example int 1, while if you store that int as a property inside a dto and use that dto as a from body parameter, the request body would look like { "MyIntegerPropertyName": 1 }. This would allow you to add additional from body parameters if you ever need them in the future and it won't break any existing consumers of your endpoint. It also adds consistency between your web api endpoint request bodies.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
I'd put auto mapper in CQRSCore. I'll note down however that I've seen a lot of people discourage it and recommend doing the mapping manually. I believe the justification was because its black magic. You are unaware of what it does underneath and can cause problems in the future.
26 replies
CC#
Created by M B V R K on 12/29/2022 in #help
❔ Need Experience Sharing
CQRSCore being the service layer should return DTOs, not entities.
26 replies
CC#
Created by Sh1be on 12/21/2022 in #help
✅ System.Text.Json serialization problem
This is now more like Required instead of Optional
222 replies
CC#
Created by Sh1be on 12/21/2022 in #help
✅ System.Text.Json serialization problem
To a non optional property
222 replies
CC#
Created by Sh1be on 12/21/2022 in #help
✅ System.Text.Json serialization problem
Try adding a default value and see if it is written
222 replies
CC#
Created by Sh1be on 12/21/2022 in #help
✅ System.Text.Json serialization problem
Are you sure you are not just testing it bad like I was? x)
222 replies
CC#
Created by Sh1be on 12/21/2022 in #help
✅ System.Text.Json serialization problem
The only way I'm able to construct an instance of this Optional class is when I pass a value inside the constructor. Hence should work
222 replies