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
G Y
1.2k
229
43.9k
ASP.NET MVC Crud Operation(delete)
Dec 15 2016 11:43 PM
For example Table B (MessageParticipant) is having a foreign key relation ship with Table A (MessageInfo) then how to remove a record from Table B (MessageParticipant).
protected override SAF.Core.FrameworkResponse Delete()
{
SAF.Core.FrameworkResponse response = new SAF.Core.FrameworkResponse();
int result = 0;
string userid = ApplicationContext.UserContext.UserID;
using (FrameworkEntities entity = new FrameworkEntities(SAF.Core.Entity.ConnectionManager.GetEntityConnection(Constants.ModuleName)))
{
base.Entity.MessageParticipant.Where(u => u.ParticipantId == userid).Where(s => s.FolderId == entity.MessageFolder.Where(m => m.Name == "Trash").FirstOrDefault().Id).FirstOrDefault().IsDeleted = true;
entity.MessageInfo.Attach(base.Entity);
entity.Entry(base.Entity).State = System.Data.Entity.EntityState.Modified;
result = entity.SaveChanges();
}
if (result > 0)
{
response.Status = SAF.Common.Status.Success;
}
return response;
}
Reply
Answers (
1
)
How to bind a data table from a Linq query
How to perform filtering based on complex field in DataTable