using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.ServiceModel;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Portal;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages

namespace plugin1

    public class Class1 :IPlugin

        public void Execute(IServiceProvider serviceProvider)

            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

           // Only Retrieve The Data From The Record On Which Plugin Is Firing
            new_teston test = (new_teston)service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet(true));

            //Select * From new_testto
            QueryExpression querry = new QueryExpression(new_testto.EntityLogicalName);

            //It Will Retrieve All Fields , If Wants Specific Field : Instead Of True Write Field Name
            querry.ColumnSet = new ColumnSet(true);

            // test1 Has All Records In Entity new_testto
            EntityCollection test1 = service.RetrieveMultiple(querry);


            // The Loop Will Run For No Of Record Available

            for (int i = 0; i <= count; i++){     
                // test11 Has All Field Value From i(1-2-3---) Records
                new_testto test11 = (new_testto)test1.Entities[i];

                if (test.new_teston1 == test11.new_name) {
                    test11.new_singlelineto = test.new_singleline;






Subscribe to our YouTube channel :