I want to use something like “In clause” of SQL SERVER.
Here are my models:
public partial class StationEvaluationBooks
{
public int StationEvaluationBookID { get; set; }
public Nullable<int> StationEvaluationID { get; set; }
public virtual StationEvaluation StationEvaluation { get; set; }
...
}
public partial class StationEvaluation
{
public StationEvaluation()
{
this.StationEvaluationBooks = new HashSet<StationEvaluationBooks>();
}
public int StationEvaluationID { get; set; }
public virtual ICollection<StationEvaluationBooks> StationEvaluationBooks { get; set; }
...
}
I used the following code to implement “In clause” by LINQ but I got error:
StationsEntities db = new StationsEntities();
var stationevaluations = db.StationEvaluation;
//some conditions:
stationevaluations = stationevaluations.Where(/*condition*/);
..
var result = from c in db.StationEvaluationBooks
where stationevaluations.Contains(c.StationEvaluationID)
select c;
Error: ‘System.Data.Entity.DbSet’ does not contain a definition for ‘Contains’ and the best extension method overload ‘System.Linq.ParallelEnumerable.Contains(System.Linq.ParallelQuery, TSource)’ has some invalid arguments
EDIT:
I want to get those books that are related to the selected evaluations in stationevaluations variable.
Getting books related to selected stations:
Or best option