using Microsoft.Xrm.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xrm;

namespace ToolsCRM
{
    public partial class WebForm_CodeBehindDataSource : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            
            //var connection = CrmConnection.Parse("Url=https://testcrmmd.api.crm4.dynamics.com; Username=Test@TestCRMMD.onmicrosoft.com; Password=50.qwaszx.50;");
            //string connectionString = "Url=https://testcrmmd.api.crm4.dynamics.com; Username=Test@TestCRMMD.onmicrosoft.com; Password=50.qwaszx.50;";
            //Microsoft.Xrm.Client.CrmConnection connection = CrmConnection.Parse(connectionString);
            
            var xrm = new XrmServiceContext("Xrm");

            //Use all contacts where the email address ends in @example.com.
            var exampleContacts = xrm.ContactSet
                .Where(c => c.EMailAddress1.EndsWith("@example.com"));

            ContactsGridView.DataSource = exampleContacts;
            ContactsGridView.DataBind();
        }
    }
}