public IQueryable getDirectory() { IQueryable queryobj = null; queryobj = from dr in this.oEFobject.DIRECTORies select new { dr.ADDRESS1, dr.ADDRESS2, dr.CITY, dr.COMPANYNAME }; return queryobj; }>>Hi All
>> public class MyBizClass >> { >> private CornMazeYellowPagesEntities oEFobject = null; >> public MyBizClass() >> { >> this.oEFobject = new CornMazeYellowPagesEntities(); >> } >> >> public Enumerable getDirectory() >> { >> //CornMazeYellowPagesEntities queryobj = null; >> var queryobj = from dr in this.oEFobject.DIRECTORies.AsEnumerable() >> select new >> { >> dr.ADDRESS1, >> dr.ADDRESS2, >> dr.CITY, >> dr.COMPANYNAME >> }; >> >> //queryobj = >> // from dr in this.oEFobject.DIRECTORies >> // select dr; >> >> return queryobj; >> } >> } >>The problem isn't with IEnumerable as such but because you are creating an anonymous type which, by definition, cannot be used outside of where it is created - i.e there's no way the object created by 'select new {}' can be used outside of the getDirectory() method. You could create a light-weight class to do the job - but define it somewhere where it can be accessible whereever it will be used.