Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi ,
i have a table with

SQL
ArticleID
Created_Date
CreatedBy
Modify_Date
Modify_By
IsActive
MemberID
ArticalTitle
ArticleTeaser
SEOFriendlyArticalTitle
ArticalDetails
CanDownloadAttachment
RoleTypeValue
ApprovedForPublish
ApprovedBy
EditorApprovalDate
TotalVisit
Ratting
TotalBooMarks
TotalDownload
TotalComments

this fields

when i update this table with

C#
db.CH_ArticleInfomation.Attach(ch_articleinfomation);


                db.ObjectStateManager.ChangeObjectState(ch_articleinfomation, EntityState.Modified);
                db.SaveChanges();

code

all fields are update
but I want to update only

C#
Modify_Date
Modify_By
IsActive

ArticalTitle
ArticleTeaser
SEOFriendlyArticalTitle
ArticalDetails
CanDownloadAttachment
RoleTypeValue
ApprovedForPublish


how do i do this in Entity Framework.
Posted
Updated 5-Apr-14 1:30am
v2

Please try is as below.This is just a sample.Adjust it according to your app.

Step 1 : Retrieve your db object which you want to update.

i.e.
SQL
var invoiceConfigobj = (from invoiceConfig in Catalog.InvoiceConfigurations
                                 where invoiceConfig.Provider.Id == providerId
                                 select invoiceConfig).SingleOrDefault();


Step 2 : After that update the fields which you want and save it back.

i.e.
C#
invoiceConfigobj.IsAllowInvoice = allowInvoice;
invoiceConfigobj.IsCustomerInvoice = customerInvoice;
invoiceConfigobj.Schedule = scheduleType;
invoiceConfigobj.ScheduleDate = scheduleDate;
Catalog.SaveChanges();
 
Share this answer
 
v2
Suppose you want to update the value of rating column. You have to write the following code
UPDATE TABLE_NAME SET RATING='" & Textbox1.text & "' WHERE ID=" & Textbox2.Text & "
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900