Avatar of cossy74
cossy74
 asked on

Entity Framework and SaveChanges

Hi,

I am new to the entity framework and have a question, which maybe silly.

public static BlogSeries BLogSeries_Save( BlogSeries source )
        {
            using ( var ctx = new BlogEngineEntities() )
            {
                ctx.BlogSeriesSet.AddObject( source );
                ctx.SaveChanges();
            }
            // What do i do to return the saved source object???
        }

Open in new window


I am trying to create an n-tier application and therefore i am doing some crud operations and what not. I need to return the changed entity after this save operation as this is important as a few things have identity columns and timestamps and what not that are populated by the SQL Server when the item is updated.

My Question therefore is:
After the SaveChanges is run, what do i need to do to return the source object that has now been saved.

C#

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck