Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to add restriction to returned dataset?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
Titre:
How to add restriction to returned dataset?
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01602693
Message ID:
01602693
Vues:
53
Hi everybody,

We have RepositoryBase class with the following two methods:
 public virtual IEnumerable<T> GetAll()
        {
            return _dbSet;
        }

        public virtual IEnumerable<T> GetAll(params string[] includes)
        {
            var query = _dbSet.AsQueryable();
            includes.ToList().ForEach(x => query = query.Include(x));

            return query;
        }
And I have a repository class for my table which has just the following code:
public class ItemTreeRepository : RepositoryBase<ItemTree>, IItemTreeRepository
    {
        public ItemTreeRepository(ISysManagerContext context) : base(context)
        {           
        }
}
I need to add the following restriction to the returned dataset for GetAll methods (parent_id = 0) (e.g. I only want to return parent nodes).

I am a bit confused as what do I need to add to my class to make this happen.

Thanks in advance.

I actually, I think, figured code for the first method (the simple GetAll), now trying to figure out where include extension came from...

How can I know which using to include for custom extension?
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform