Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:17:58+00:00 2026-05-25T10:17:58+00:00

I am trying to Update records in the OpportunitySet using LINQ. Right now I

  • 0

I am trying to Update records in the OpportunitySet using LINQ. Right now I am pulling all the data down and they are being Databound to fields in a Grid. This is what I have so far:

        Uri organizationUri = new Uri("http://servername/XRMServices/2011/Organization.svc");
    Uri homeRealmUri = null;
    ClientCredentials credentials = new ClientCredentials();
    credentials.Windows.ClientCredential = new System.Net.NetworkCredential("user", "pass", "domain");
    OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
    // Get the IOrganizationService
    IOrganizationService orgService = (IOrganizationService)orgProxy;
    //Get OrganizationServiceContext -the organization service context class implements the IQueryable interface and
    //a .NET Language-Integrated Query (LINQ) query provider so we can write LINQ queries against Microsoft Dynamics CRM data.
    OrganizationServiceContext orgServiceContext = new OrganizationServiceContext(orgService);


    var linqQuery = (from r in orgServiceContext.CreateQuery("opportunity")
                     join a in orgServiceContext.CreateQuery("account") on ((EntityReference)r["accountid"]).Id equals a["accountid"]
                     join c in orgServiceContext.CreateQuery("contact") on ((EntityReference)r["new_contact"]).Id equals c["contactid"]
                     where ((EntityReference)r["new_channelpartner"]).Id.Equals(new Guid("c55c2e09-a3be-e011-8b2e-00505691002b"))
                     select new
                     {
                         OpportunityId = !r.Contains("opportunityid") ? string.Empty : r["opportunityid"],
                         CustomerId = !r.Contains("customerid") ? string.Empty : ((EntityReference)r["customerid"]).Name,
                         Priority = !r.Contains("opportunityratingcode") ? string.Empty : r.FormattedValues["opportunityratingcode"],
                         ContactName = !r.Contains("new_contact") ? string.Empty : ((EntityReference)r["new_contact"]).Name,
                         Source = !r.Contains("new_source") ? string.Empty : r["new_source"],
                         CreatedOn = !r.Contains("createdon") ? string.Empty : r["createdon"],
                         State = !a.Contains("address1_stateorprovince") ? string.Empty : a["address1_stateorprovince"],
                         Zip = !a.Contains("address1_postalcode") ? string.Empty : a["address1_postalcode"],
                         Eval = !r.Contains("new_colderevaluation") ? string.Empty : r.FormattedValues["new_colderevaluation"],
                         EvalVal = !r.Contains("new_colderevaluation") ? string.Empty :((OptionSetValue)r["new_colderevaluation"]).Value.ToString(),
                         DistributorName = !r.Contains("new_channelpartner") ? string.Empty : ((EntityReference)r["new_channelpartner"]).Name,
                         ContactStreetAddress = !c.Contains("address1_line1") ? string.Empty : c["address1_line1"],
                         ContactCity = !c.Contains("address1_city") ? string.Empty : c["address1_city"],
                         ContactState = !c.Contains("address1_stateorprovince") ? string.Empty : c["address1_stateorprovince"],
                         ContactZip = !c.Contains("address1_postalcode") ? string.Empty : c["address1_postalcode"],
                         ContactPhone = !c.Contains("telephone1") ? string.Empty : c["telephone1"],
                         ContactMobilePhone = !c.Contains("mobilephone") ? string.Empty : c["mobilephone"],
                         ContactEmail = !c.Contains("emailaddress1") ? string.Empty : c["emailaddress1"],
                         Notes = !r.Contains("new_rsmnotes") ? string.Empty : r["new_rsmnotes"],
                         EstimatedCloseDate = !r.Contains("estimatedclosedate") ? string.Empty : r["estimatedclosedate"],
                         MaturityValue = !r.Contains("estimatedvalue") ? string.Empty : ((Money)r["estimatedvalue"]).Value.ToString()
                     });

    grdLeadList.DataSource = linqQuery;

    grdLeadList.DataBind();

This code pulls all my information down and then assign it to controls using something like:

<asp:TestBox ID="Label1" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.ContactEmail" ) %>' />

But now I am trying to make it so when you click a save button it will save any changes in the textbox. How would I do that using LINQ?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:17:58+00:00Added an answer on May 25, 2026 at 10:17 am

    If you’re not stuck to some architecture yet, I would suggest you use a proven pattern like MVVM or take a look at Microsoft’s MVC project. You are using an anonymous class genereated by Linq to communicate with the UI, so there is a direct link between UI and your data access layer. In other words, there is no separation of concerns. This is very problematic. For instance, where do you program your validation logic? This will probably develop into large monoliths with lots of copy-and-paste programming.

    It always takes a lot of effort and learning and, thus, time to set up a basic architecture, but postponing it will in the end be far more time-consuming and certainly less fun! So I hope time and prerequisites allow you to go this path. In my team, even for pilot projects I encourage people to always decide on architecture first because pilot projects have a way of developing into nasty persistent projects that you never get rid of.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update all records in a column so that they start
I am trying to update a table using LinQ. Though records are getting inserted,
I'm trying to update a collection of records in my database using ActiveRecord's update_all.
I am trying to update a LARGE MyISAM table (25 million records) using a
I am trying to update multiple records in the table using the temporary table
I'm trying to build a form that allows users to update some records. They
I was trying to update approx 20,000 records in a table by using statements
I'm trying to update many active records at the same time using the :update
So I'm trying to update my RadRadialGauge. It will display data (using an animated
I am trying to update records in a .DAT file using fread and fwrite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.