Entity Framework ExecuteFunction DBContext not refreshing entity?

Hello all,

I have a issue where I am using unit of work with entity framework.   When I add or update via a table entity then do a .Add then .Commit(). for example everything works beautifully.   Problem is not I am using a ExecuteFunction call with generic <T> to call a proc but the underlying table entity is not refreshed with that procs update to a record.  

        public ObjectResult<T> StoredProc<T>(string pName, params ObjectParameter[] pParams)
            return ((IObjectContextAdapter)this.DbContext).ObjectContext.ExecuteFunction<T>(pName, pParams);

Any idea how I refresh the underlying entity in this case?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi sbornstein2;

The default behavior of this function is AppendOnly. Therefore if an entity already exist in the data contact then if a record is returned from the call that has the same primary key then it will NOT overwrite the record in the data context. Use the following function,

public ObjectResult<TElement> ExecuteFunction<TElement>(
	string functionName,
	MergeOption mergeOption,
	params ObjectParameter[] parameters

Open in new window

and modify the MergeOption to one that will apply the returned values in the way you need. Please see the MergeOption Enumeration web page for the options and there meaning.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.