Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for Marc.2377
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #280662 |
I deleted it myself due to poor reception. Never liked that site anyway. [Here's an archived version](https://web.archive.org/web/20210209211132/https://softwareengineering.stackexchange.com/questions/421833/how-best-to-implement-a-data-access-layer-for-this-architecture). (more) |
— | almost 4 years ago |
Comment | Post #280670 |
I am aware of the XY nature of this question, but asked it anyway because I wanted to know whether this could be done, since the entire thing is an exercise to get a better grasp of the language and its capabilities. I'm satisfied with the response. (more) |
— | almost 4 years ago |
Comment | Post #280670 |
My final goal is to have an interface to be able to use EF Core in my application services layer while enforcing that whatever custom DbContext-like implementations an user might want to implement in the future provides the same set of functionality in order to require minimal changes to the applicat... (more) |
— | almost 4 years ago |
Comment | Post #280666 |
Good point. I think I have one use case for updating both the relational and document datastores in one atomic operation, but for the majority of cases you are correct. (more) |
— | almost 4 years ago |
Comment | Post #280670 |
I think I got it, if you may have a look at my answer below, tell me if that makes sense and is correct. (more) |
— | almost 4 years ago |
Edit | Post #280671 | Initial revision | — | almost 4 years ago |
Answer | — |
A: Declaring interface members with generic return types: "The type parameter [generic type] cannot be used with type arguments" I believe an implementation of the answer by Peter Taylor above would be: ```cs public override EntityEntry Add([NotNullAttribute] TEntity entity) where TEntity : class { return Add(entity, base.Add); } public TEntityEntryTEntity Add([NotNullAttribute] TEntity entity, [NotNull... (more) |
— | almost 4 years ago |
Comment | Post #280670 |
... and/or, how the implementation of this interface should be done. (more) |
— | almost 4 years ago |
Comment | Post #280670 |
Thanks. Could you give an example of what the factory method implementation would look like? (more) |
— | almost 4 years ago |
Comment | Post #280665 |
@FoggyFinder is that so I can enforce new user-created context types to provide the same set of methods.
(more) |
— | almost 4 years ago |
Comment | Post #280665 |
@FoggyFinder yes, the interface must be applicable to the method already defined in the base class, which in this case is part of the framework.
(more) |
— | almost 4 years ago |
Comment | Post #280666 |
... and when some queries will be made to both databases, sharing a `TransactionScope`.
(more) |
— | almost 4 years ago |
Comment | Post #280665 |
... then the only valid implementation would be: `public EntityEntry Add<TEntity>(TEntity entity) where TEntity : class` - but I want the implementation that already exists in the base class (`DbContext`) to be valid. And its signature returns `EntityEntry<TEntity>`.
(more) |
— | almost 4 years ago |
Comment | Post #280665 |
@FoggyFinder I tried, but then in my class that inherits from `DbContext` I get: `Error CS0738 'EntityFrameworkContext' does not implement interface member 'IDbContextable<EntityFrameworkContext, EntityEntry>.Add<TEntity>(TEntity)'. 'DbContext.Add<TEntity>(TEntity)' cannot implement 'IDbContextable<E... (more) |
— | almost 4 years ago |
Comment | Post #280666 |
Thanks. Does your approach change in any way in the case where the secondary database is non relational? (more) |
— | almost 4 years ago |
Edit | Post #280665 | Initial revision | — | almost 4 years ago |
Question | — |
Declaring interface members with generic return types: "The type parameter [generic type] cannot be used with type arguments" I'm trying to write an interface to define the set of operations I expect my repositories' Unit of Work implementations to have, and I want this interface to be fulfilled by EF Core's `DbContext` class. So far this is what I got: (I know the name is awful, suggestions accepted): ```cs public i... (more) |
— | almost 4 years ago |
Comment | Post #280662 |
Posted a more elaborate/specific version of this to Software Engineering SE: [How best to implement a Data Access layer for this architecture?](https://softwareengineering.stackexchange.com/q/421833/183949) (more) |
— | almost 4 years ago |
Edit | Post #280662 |
Post edited: |
— | almost 4 years ago |
Edit | Post #280662 |
Post edited: |
— | almost 4 years ago |
Edit | Post #280662 | Initial revision | — | almost 4 years ago |
Question | — |
How to separate DB query logic from the application other than implementing a repository on top of an ORM? I've been doing a lot of reading on implementing the repository pattern in C# projects and found controversy, or shall I say some strong criticism, made by seemingly very smart people with previous experience with the pattern, saying that one is better off not implementing a repository on top of an O... (more) |
— | almost 4 years ago |
Edit | Post #278924 |
Post edited: copy-edit |
— | about 4 years ago |