Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

We are facing some issues in making a left outer join between custom list to entities.

Here is the code we are trying to implement:

C#
public class custd
        {
            public int BatchReportFileId { get; set; }
            public string UserName { get; set; }
        }

        public void getData()
        {
            List<custd> CustomData = new List<custd>()
                           {
                           new custd() {BatchReportFileId   = 1,  UserName ="Atul , Anil" },
                           new custd() {BatchReportFileId   =2,    UserName= "Abc, Xyz"},
                           new custd() {BatchReportFileId   =3,    UserName= "Subhash, Kaushal"}
                           };
            using (ReportDistToolModelContainer context = new ReportDistToolModelContainer())
            {
                var CustmerDetails = (from Brf in context.BatchReportFile
                                      join Cust in CustomData on Brf.BatchReportFileId equals Cust.BatchReportFileId into Cust_Join
                                      from Cust in Cust_Join.DefaultIfEmpty()
                                      select new { Brf.BatchReportFileId ,
                                                   Cust.UserName ,
                                                   Brf.BatchReportFileName }).ToList();

            }
        }

While making a join between custom list vs entity its giving error.


Here is the error we are encountering:

Unable to create a constant value of type 'custd. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900