Entity framework load from view save to table

c# entity-framework-6 repository-pattern

Popular Answer

Thank you for the responses. I suppose I could have used a stored procedure as well, however I had my DBA create an INSTEAD OF trigger for insert instead.

Possibly like this:

CREATE TRIGGER tr_vWorkshop_InsteadOfInsert ON [SDWorkshop].[vWorkshop]
INSTEAD OF INSERT
AS
BEGIN
    INSERT INTO SDWorkshop.Workshop
            ({columns here})

        SELECT      
             {columns here}

        FROM inserted
END

SELECT [Workshop_ID] FROM [SDWorkshop].[Workshop] 
WHERE @@ROWCOUNT > 0 AND [Workshop_ID] = SCOPE_IDENTITY() 

Entity Framework will assume that nothing was produced if the bottom select does not yield the ID of the newly formed entry.

1
3/1/2018 8:14:23 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow