Link to home
Start Free TrialLog in
Avatar of sreejithm
sreejithm

asked on

Updating accounts - MS CRM 2013

Hello.

I have a requirement where one of the fields of the account entity called ArabicName needs to be updated from our legacy database.

My logic is to retrieve the account based on the accountnumber and then use the below code to update the field.

Entity account = new Entity("account");
            account.Attributes["accountnumber"] = 528580;
            account.Attributes["arabicname"] = "xyz";
            _service.Update(account);

However the code does not seem to work.  My logic is incorrect and i feel that the record needs to be retrieved based on the GUID. Could you please provide any sample code that will help me to achieve the required functionality ?

Regards.
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

I hope in your Entity framework Context is being used. In this case below code could help you.

Assuming that context exists and Account is a class which holds the account information.

Account account = context.Accounts(I => i.accountnumber = 528580)
account.ArabicNme = "xyz";
_service.Update(account);

Open in new window


Please refer http://www.dotnetcurry.com/entityframework/619/add-update-delete-objects-entity-framework and http://www.codeproject.com/Articles/37932/Simple-Sample-with-Entity-Framework for idea.
SOLUTION
Avatar of Feridun Kadir
Feridun Kadir
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sreejithm
sreejithm

ASKER

Apologies for the delay in my response. The delay was due to some personal emergency.