Comments (6)
And I don't think such specifications are needed by the applicationcore.
Want some guide, thanks!
from eshoponweb.
Specification is meant to encapsulate complex queries. If you just want to know if a record exists, you can do a GetById()
and see that it returns null - no Spec needed.
from eshoponweb.
but in my case, the query is not by id, but other field like studentnumber
from eshoponweb.
In that case if you're already using specs in your design, it would be easy to create a spec for StudentByStudentNumber(int studentNumber) that would include the required lambda expression to fetch student(s) with that number.
Alternately unless you expect it to be a regular occurrence for student creation to result in potential duplicates, you could just attempt the create and catch the exception when the record already exists. If it truly is an exceptional condition, this would be an appropriate design as well.
from eshoponweb.
In fact it would not cause an exception, because I use soft delete, with a IsDeleted field in each table.
Such checks can only be performed manually since there is no unique index.
So the answer is creating specs to do the job?
from eshoponweb.
If you're already set up to use Specifications (that is, your Repository can accept an ISpecification<T>
or similar) then yes, a spec would do the job easily. If you're not using the Specification pattern or don't want to use it for this case, the simplest approach would be to create a method on your interface (example: IStudentRepository
has method GetStudentByStudentNumber(int number)
). The reason I don't prefer this approach is it results in bigger repositories and more repository interfaces and classes. I'd rather have the specification classes, which better follow SRP, than many inconsistent IWhateverRepository
implementations, given the choice. Hope that helps.
from eshoponweb.
Related Issues (20)
- OBE
- Verify devcontainer for codespaces debugging HOT 6
- Modernize to .NET SDK Containers
- Inconsistent naming of async methods HOT 1
- How to connect to the postgres instance from the host ? HOT 1
- Shopify manager HOT 2
- public api get catalog brands throws error HOT 1
- How to debug this project using VS Code? HOT 1
- Architect Modern Web Applications edition 7th not available as PDF HOT 2
- incorrect about section in github description HOT 1
- Inject IHttpContextAccessor to CatalogContext's constructor will be destoryed when RevokeAuthenticationEvents.cs handle about CatalogContext's data
- The style class prefix "col-xs-*" didnt work in cshtml files. HOT 1
- Changelog for the latest version, updated to .NET 7, is not available in the wiki page HOT 4
- Update to bootstrap 5
- .NET 8 Updates HOT 5
- Facing issue when deploying the application on azure app service HOT 2
- I am not able to deploy the application to Azure from Visual Studio Code HOT 1
- I'm not able to update in memory database HOT 1
- Update NuGet packages to latest versions HOT 1
- Revalidate AZD HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eshoponweb.