locked
join two custom list using linq. RRS feed

  • Question

  • Hi All,

    Does it possible to join (inner join) between two custom list using linq query?

    Regards Amit

    Thursday, June 21, 2012 7:25 AM

Answers

All replies

  • I came across below link while search this on goggle. It seems to me that it is possible to have the join between two custom list. I have question here, is it feasible performance wise? It seems to me that linq will first fetch the data in memory and perform the join which doesn't seem correct to me. Please provide me your suggestions.

    http://rmanimaran.wordpress.com/2011/07/25/sharepoint-join-query-using-lambda-expression-in-sharepoint-list/

    Thursday, June 21, 2012 7:34 AM
  • var x = from cust in dataContext.Customers.ToList()
                        join ord in dataContext.Orders.ToList()
                        on cust.CustomerID.ToString().Trim() equals    
                        ord.CustomerID.CustomerID.ToString().Trim()
                        select new
                        {
                            CustomerID = cust.CustomerID,
                            Title = cust.Title,
                            City = cust.City,
                            CustomerCountry = cust.CustomerCountry,
                            JoiningDate = cust.JoiningDate,
                            OrderTitle = ord.Title
                        };
                dataGrdCustomer.DataSource = x.ToList();
    Thursday, June 21, 2012 7:36 AM
  • Hi Amit,

    Please take a look at this thread with another possible solutions How can i join 2 sharepoint 2010 list


    Dmitry

    Lightning Tools LogoLightning Tools Check out our SharePoint tools and web parts | Lightning Tools Blog

    Thursday, June 21, 2012 10:05 AM