urfnet / URF.Core

Unit of Work & Repositories Framework - .NET Core, NET Standard, Entity Framework Core. 100% extensible & lightweight.
https://github.com/urfnet
MIT License
309 stars 62 forks source link

How to store Header and Detail relation data? #49

Closed vinayaroraincedo closed 5 years ago

vinayaroraincedo commented 6 years ago

I'm trying to store Header and Detail relation data using Insert function for URF.Core.Services.

_notificationService.Insert( new Notifications() { ClientId = command.ClientId, ClientNotificationTemplateId = command.ClientNotificationTemplateId, ConsumerId = command.ConsumerId, NotifiationType = command.NotifiationType, NotificationDetails = new List() { new NotificationDetails(){ Body = command.Body, NotifiationType = command.NotifiationType, RecepientAddress = command.RecepientAddress , Subject = command.Subject, CreatedOn = DateTime.Now, CreatedBy = 123, IsActive = true, IsDeleted = false, TrackingState = TrackingState.Added} }, Status = command.Status, CreatedOn = DateTime.Now, CreatedBy = 602737, IsActive = true, IsDeleted = false

            });

Do I have to set some parameters in the service call?

Crazybutch commented 6 years ago

Maybe you are searching for this: https://github.com/urfnet/URF.Core/issues/37

vinayaroraincedo commented 6 years ago

Thanks @Crazybutch, now its working. But one thing if I want a id for newly added entity than how can i get those id?

Crazybutch commented 6 years ago

@vinayaroraincedo I'm creating the Id in my Code Id = Guid.NewGuid(); because SaveChanges just returns the count of saved datasets (rows?)

I set the Id on my Dto - AutoMapper to -> Entity and after successful SaveChanges() > 0 I know that my self created Id is valid.

lelong37 commented 5 years ago

This is an EF issue, unrelated to URF, closing.