Wednesday 20 February 2013

Cannot implicitly convert type 'System.Linq.IQueryable<  to 'System.Data.Entity.DbSet<

More Info:

 Replace
        public List<StyleMaster> getStyle([QueryString("id")] int? groupId)
        {
            using (CompanyTestEntities db = new CompanyTestEntities()){
               var  result = db.StyleMasters;
                if (groupId.HasValue && groupId > 0){
                    result = result.Where(s => s.GroupId == groupId);
                }
                return result.ToList();
            }

        }
With

        public List<StyleMaster> getStyle([QueryString("id")] int? groupId)
        {
            using (CompanyTestEntities db = new CompanyTestEntities()){
                IQueryable<StyleMaster> result = db.StyleMasters;
                if (groupId.HasValue && groupId > 0){
                    result = result.Where(s => s.GroupId == groupId);
                }
                return result.ToList();
            }

        }

No comments:

Post a Comment