Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add restriction to returned dataset?
Message
 
 
To
27/06/2014 13:06:55
General information
Forum:
ASP.NET
Category:
Entity Framework
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01602693
Message ID:
01602702
Views:
36
>Include is a function of either a DbQuery (http://msdn.microsoft.com/en-us/library/gg696785%28v=vs.113%29.aspx) or ObjectQuery(http://msdn.microsoft.com/en-us/library/bb738708%28v=vs.110%29.aspx). DbSet is a subclass of DbQuery (http://msdn.microsoft.com/en-us/library/system.data.entity.dbset%28v=vs.113%29.aspx). If you want to use include, you need to do so on either the DbSet or a DbQuery. AsQueryable and Where return IQueryable or IEnumerable respectively, not DbQuery.
>
>Also, the title of this thread have nothing to do with the actual contents. You aren't dealing with DataSets, and you are trying to include additional data to the results, not restrictions.

Hi Rob,

Do you know what the base class is doing with this code
 public virtual IEnumerable<T> GetAll(params string[] includes)
        {
            var query = _dbSet.AsQueryable();
            includes.ToList().ForEach(x => query = query.Include(x));

            return query;
        }
?

May be for now I'll not try to change this method. For my purpose I need to return not all rows from the table, but just the ones where parent_id = 0. So, I made a change in the first method which I am going to test and I am not sure what do to with the second method and if I need it or not.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform