0
 var query = from cl in
                 (
                     from cl in _dataContext.Set<CLIENT>()
                     from cr in
                         _dataContext.Set<CLIENT_REL>()
                             .Where(m => m.CLIENT_CHILD_ID == cl.CLIENT_ID)
                             .DefaultIfEmpty()
                             .AsEnumerable()

                     select new {cl.CLIENT_ID, cl.CLIENT_NAME, cr.CLIENT_PARENT_ID, cl.CLIENT_CODE, cl.CLIENT_DESCR}
                     )
                 from pcl in
                     _dataContext.Set<CLIENT>().Where(p => p.CLIENT_ID == cl.CLIENT_PARENT_ID).DefaultIfEmpty()

                 select new ClientDetail
                 {
                     ClientId = cl.CLIENT_ID,
                     ClientName = cl.CLIENT_NAME,
                     ClientCode = cl.CLIENT_CODE,
                     ClientDescription = cl.CLIENT_DESCR,
                     ParentName = pcl.CLIENT_NAME
                 };

is throwing the following System.NotSupportedException

LINQ to Entities does not recognize the method 'System.Data.Entity.DbSet`1[Ika.Security.Data.Model.CLIENT_REL] SetCLIENT_REL' method, and this method cannot be translated into a store expression.

What am I doing wrong ?

har07
  • 88,338
  • 12
  • 84
  • 137
Sat
  • 133
  • 2
  • 12
  • I don't think you can call `_dataContext.Set` like you are from within the query. LINQ isn't able to translate that into a query. Looks like you're loading a dataset (using AsEnumerable) and using that dataset within the query, which you're not allowed to do. You'll need to restructure it or make it two separate queries. Unfortunately I can't give you better advice, I'm not fully sure what your query is doing, I'm more familiar with the lambda syntax. – cost Apr 19 '14 at 01:08
  • If you are trying to join the tables you will want to use the linq join and not the where as if you are writing t-sql. Also cost is correct you cannot use AsEnumerable because it needs to be iqueryable for it to translate correctly – CharlesNRice Apr 19 '14 at 01:56
  • Which database and data provider is this? – Gert Arnold Apr 19 '14 at 10:03
  • Oracle database and Oracle Managed access provider' – Sat Apr 20 '14 at 03:40
  • I tried lambda and that seems to working ... Lambda is converting it into inner join what I want is left ;Will post equivalent lambda query once am done... – Sat Apr 20 '14 at 03:42
  • possible duplicate of [LINQ to Entities does not recognize the method](http://stackoverflow.com/questions/4767596/linq-to-entities-does-not-recognize-the-method) – Özgür Kara Nov 07 '14 at 08:46
  • dublicate question http://stackoverflow.com/questions/4767596/linq-to-entities-does-not-recognize-the-method – Özgür Kara Nov 07 '14 at 08:46

0 Answers0