Linq query to Nlinq i.e. linq to memory RRS feed

  • Question

  • I tried the specific column and all column using the LINQ and it’s executing fastly. But We are facing issue in NLINQ, when LINQ query is converting to NLINQ query passing as a string i.e. ‘link to memory’ then it is taking infinite time. Kindly help me this issue and please advise me if any other way is there to retrieve data.

    The below code is:-

    static void Main(string[] args)
                CrmConnection con = new CrmConnection();

                IOrganizationService Service = con.Service("*********", "*********", "", "https://*****");

                using (var context = new ServiceContext(Service))
                    NLinqQuery query = new NLinqQuery(@"from c in entityname
                                      join a in address on c.ContactId equals a.PrimaryContactId.Id                        
                                     select new {

                    List<object> n = new List<object>();

                    LinqToMemory linq = new LinqToMemory(query);
                    linq.SetParameter("entityname", context.ContactSet);
                    linq.SetParameter("address", context.AccountSet);

                    Stopwatch sw = Stopwatch.StartNew();
                    IList result = linq.List();

                    Console.WriteLine("Total Count " + result.Count);
                    Console.WriteLine("Time taken: {0}s", sw.Elapsed.Seconds);


    Tuesday, August 1, 2017 7:20 AM