- Alter the paths of the individual Get, Put, and Delete endpoints to contain two (or more, depending on how many keys are in your composite) parameters, and then alter the method parameters to match. This requires careful consideration as there are many different ways you can structure the parameters in your route.
- Alter every usage of _context.nameOfModelHere.FindAsync to contain all components of your primary key. Look at the model’s Entity definition in your database context class, specifically the usage of entity.HasKey, to determine the order in which to list the components in your key to FindAsync.
- Alter the nameOfModelHereExists method to take the correct amount of parameters for your key. Adjust the body of the method accordingly to check all parts of the key; I just added && at the end of the existing equality expression, and added more equality expressions.
- Alter all usages of nameOfModelHereExists appropriately.
- In the Put method, alter the second if statement to check all the components of your primary key, rather than just id.
- In the Post method, adjust the CreatedAtAction call in the return statement to contain all the components of your primary key.
- I would also recommend updating all the auto-generated comments that EntityFramework put in to keep things consistent.
Sunday, 31 March 2019
Monday, 18 March 2019
So I’ve decided to start blogging again. You should be able to expect a myriad of topics from me, mainly with a focus on software development and my love for public transport.
In terms of the tools I’ve decided to equip myself with; the blog itself is hosted on Blogger, and I’m authoring the posts with Open Live Writer, giving the whole experience for me a very late-2000s feel. I’m not sure for how long I’ll be able to put up with this for.
Until next time…