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
598.4k
Error attaching entity of id when trying to update MVC5
Feb 20 2017 4:12 AM
Hi,
I am getting error whed trying to update table.
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)
{
Partner t_EntityModified = t_Context.Partners.Single(m => m.idPartner == t_Entity.idPartner);
t_Entity.LoginName = t_EntityModified.LoginName;
t_Entity.Password = t_EntityModified.Password;
t_Entity.PartnerTypeName = t_EntityModified.PartnerTypeName;
t_Entity.IncorporationType = t_EntityModified.IncorporationType;
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;
}
Reply
Answers (
2
)
Why we can not create instance of static class
how to perform multipilication and devide in asp.net