Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to add restriction to returned dataset?
Message
 
 
À
27/06/2014 14:17:09
Information générale
Forum:
ASP.NET
Catégorie:
Entity Framework
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:
01602726
Vues:
38
>I forgot to include the where clause:
public virtual IEnumerable< T> GetAll(params string[] includes)
>        {
>            DbQuery query = _dbSet;
>            foreach(x in includes)
>                        query = query.Include(x);
>            
>            var retVal = query.Where(entity => entity.condition);
>            return retVal;
>        }
>
>I don't know whats in your Adapter or Repository class, so I can't tell you where the code should be added. That is something best left to you and your coworkers.
>
>If you want to return only 2 or 3 columns, you need to add a Select clause and create a new instance of a different model, an anonymous object, or a dynamic object.

This is all seems to be too complicated :(

I think that actually this method is executed:
public PagedResult<ItemTree> GetPagedRequest(QueryRequest queryRequest)
		{
            // TO DO: uncomment and modify Field and Value below to exclude blank records from paged request, if necessary
			 queryRequest.FilterInfo.Filters.Add(new FilterItem { Field = "parent_id", Operator = "==", Value = 0 });
			
			return _itemTreeRepository.GetPagedRequest(queryRequest);
		}
So, since it had TO DO I hope my change is going to work here.

The problem is that it returns ItemTree entity which has too many columns. All the models are actually auto-generated using EDMX and run custom tool method.

So, suppose I wanted to create an ItemTreeSimple model (or something along the lines), I am not exactly sure where to add this simple model.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform