TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
530
2.4k
600.5k
EntityState.Modified not working properly
Feb 16 2017 1:36 AM
Hello everyone,
I am MVC5, I have Parter table in the SQL Server DB. And I am using Entitty Framework to Save and Update the table. I am saving the data two times from different views. But null updating 1st saved data after saving second data.
public
static
int
Partner_AddUpdate(Partner t_Entity)
{
int
retValue = -1;
using
(var t_Context =
new
ReboxEntities())
{
using
(var transaction = t_Context.Database.BeginTransaction())
{
try
{
if
(t_Entity.idPartner > 0)
{
t_Context.Entry(t_Entity).State = System.Data.Entity.EntityState.Modified;
}
else
{
t_Context.Entry(t_Entity).State = System.Data.Entity.EntityState.Added;
}
t_Context.SaveChanges();
retValue = t_Entity.idPartner;
transaction.Commit();
}
catch
(Exception exc)
{
transaction.Rollback();
}
}
}
return
retValue;
}
Please help me...
Reply
Answers (
2
)
Can anyone pls tell me how to publish asp.net project in iis
How to Implement remember me in Asp.net Mvc