ASP.NET Core Web API + Entity Framework Core : Saving Related Data - EP05

preview_player
Показать описание
Hey Coders,

In this #ASP.NET #WebAPI #EntityFramework Core tutorial, I am going through steps on how you can save related data using EntityFramework and how you can pass related JSON to create related data.

Content -
1. Saving related data using objects
2. Saving related data using #JSON

#CuriousDrive #WeLoveCoding
Рекомендации по теме
Комментарии
Автор

Thanks for watching, please share with your friends :)

CuriousDrive
Автор

Hello Fahad, I am glad to be the first one to congratulate you for the new Episode
Please keep on the excellents tutorials.
BTW. I was stuck on how to save related data and now you guided me on that.
Thank you much indeed.

talkathiriify
Автор

I just wanted to Pause to thank you for what for this absolutely fantastic series! Just completed ep 4 and I have learnt so much! So I wanted to break to thank you! Thank You so much and really appreciate the care in your explanations and you also remembering to include your extra note and sql data... in the repo.
Thanks Again!!!

shollymore
Автор

Thank you for an easy to follow example. I have subscribed to your channel!! :-) - And thank you for sharing code, so it easy for other to see the details in the examples! Great work!

EsbenKielS
Автор

thank you so much from the hearth you have solved a big problem to me with relationship between tables, you are opoened many door to me

brirembillel
Автор

Tutorial is very good. Are there any new series on .Net 6/7/8/ Web api??

kandinagireddy
Автор

Very nice tutorial but would like to know how does update works for related data

ansarifamily
Автор

thanks for creating such great tutorial
in you create tutorial for asp.net core web forms also.

codingfaculty
Автор

Boa noite meu amigo, tenho uma uma duvida com relação ao UPDATE. Quando faço o UPDATE não atualiza as entidade "Filhas". Tenho que fazer o update separadamente, tabela por tabela ou tem alguma forma de fazer igual ao create que gera o id para as tabelas filhas?

var avoidingAttachedEntity = await GetByIdAsync(obj.Id);
= EntityState.Detached;

var entry = dbContext.Entry(obj);
if (entry.State == EntityState.Detached) dbContext.Attach(obj);

dbContext.Entry(obj).State = EntityState.Modified;
return await dbContext.SaveChangesAsync();

Atualmente meu repositorio de update esta assim, porém tenho que atualizar tabela por tabela.
Obrigado e continue com os vídeos, você é melhor do que muitos professores aqui do Brasil. Grande Abraço

joaomiranda
Автор

thank you for the videos, does evreything works on entityframework core 2.0 ?

martinlarocque
Автор

Hi Curious Drive
When i tried to save Related DataI am getting Error as
"The INSERT statement conflicted with the FOREIGN KEY constraint".

How you overcome this?

mailsvijayakumar
Автор

Hi, I have an issue with saving cart. It saves cart but doesn't save product.cartId even though cart has id it shows null

muhammeda
Автор

hi fahad.

i have followed the method you teach with slight different based on json { "operator": "SearchPersonList", "info": { "DeviceID": 1379151, "Listnum": 1, "Totalnum": 3, "List": [ { "LibID": 8, "Name": "Mohd Rosdi"}]}}
the db setup are :
Class Operator ( one to one relationship) to class Info
class list (one to many) to info
however after creating the controller and posting the json from device or from postman causing the it save infinity relationship lopping to database.

are there other way to map the json to the database and call it back with httpget?

cudid
Автор

How can I add a created book to one new sale? Please help me :(

JuanM-ckjg
Автор

Hi Fahad, You are just awesome. I liked your teaching method. Thaks for this detailed series.
I am facing problem in Saving Related Data. I am using it in dotnet 6. Its showing me the following error :

{
"errors": {
"Books[0].Pub": [
"The Pub field is required."
],
"Books[1].Pub": [
"The Pub field is required."
],
"Books[0].Sales[0].Book": [
"The Book field is required."
],
"Books[0].Sales[0].Store": [
"The Store field is required."
],
"Books[1].Sales[0].Book": [
"The Book field is required."
],
"Books[1].Sales[0].Store": [
"The Store field is required."
]
},
"title": "One or more validation errors occurred.",
"status": 400,
"traceId":
}

ImonIslam