int' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains(IQueryable, string)' requires a receiver of type 'IQueryable
This is part of the code of the Controller:
var projects = db.Projects.Include(p => p.Engineer).Include(p => p.SiteLocation);
// var projects = from p in db.Projects
// select p;
if (!String.IsNullOrEmpty(searchString))
{
projects = projects.Where(p => p.NumberMCP.Contains(searchString)
|| p.nameProject.Contains(searchString) ||
p.Ptype.Contains(searchString) || p.EngineerID.Contains(searchString));
}
Projects Model
public partial class Project
{
public int ProjectID { get; set; }
[DisplayName("MCP")]
[Required(ErrorMessage = "NumberMCP es requerido")]
public string NumberMCP { get; set; }
[DisplayName("Ingeniero")]
[Required(ErrorMessage = "Tarjeta Ingeniero es requerido")]
public int EngineerID { get; set; }
[DisplayName("Localidad")]
[Required(ErrorMessage = "ID Localidad es requerido")]
public int SiteLocationID { get; set; }
[DisplayName("Descripción")]
[Required(ErrorMessage = "Descripción es requerido")]
public string nameProject { get; set; }
[DisplayName("Tipo Proyecto")]
[Required(ErrorMessage = "Tipo Proyecto es requerido")]
public string Ptype { get; set; }
[DisplayName("A?o")]
[Required(ErrorMessage = "A?o es requerido")]
public Nullable<int> Pyear { get; set; }
[DisplayName("Link del Proyecto")]
[Required(ErrorMessage = "Link del Proyecto")]
public string Plink { get; set; }
public virtual Engineer Engineer { get; set; }
public virtual SiteLocation SiteLocation { get; set; }
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…