Hi,
I am developing an application with RIA Services, and in my DomainService class, I have all that standard functions generated by the RIA for general CRUD operations. The problem is that I tryed to create my own function that insted of listing all the the 45 columns in the Select statment, would list only 2 (NOM and PRENOM) and also according the parameters received in the clause Where.
The Clause conditions are working perfectly, but the code is still returning all the 45 Columns instead of only the 2 specified. Here is the code:
public IQueryable<EMPLOYE> GetEMPLOYEs(string strPRENOM, string strNOM)
{
IQueryable<EMPLOYE> query = this.Context.EMPLOYEs.AsQueryable();
//This Doesn't work... all 45 clomuns are returned!!!
query = from e in this.Context.EMPLOYEs select e;
query.Select(e => new { e.PRENOM, e.NOM });
// This Doesn't Work too!!!! Error:Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'System.Linq.IQueryable<AffPoste.Web.EMPLOYE>'. An explicit conversion exists (are you missing a cast?)
//query = from e in this.Context.EMPLOYEs select new{e.PRENOM, e.NOM};
// Clause Conditions "Where"
if (!String.IsNullOrEmpty(strPRENOM)) query = query.Where(e => e.PRENOM.Contains(strPRENOM));
if (!String.IsNullOrEmpty(strNOM)) query = query.Where(e => e.NOM.Contains(strNOM));
return query;
}
Thanks In Advance.