I have a model class that stores information in the datatbase. then I created a list test. This lists get xml data and puts its in a list.
so in my controller,
I have this linq query:
function somefunction()
{
var mov = from m in db.Movies
select m;
List<Movie> items = MyXMLExtract();//this gets xml file from a url, then returns a list<Movie>.
var thistest = mov.ToList().Concat(items);; //I concatenate the two linq
return thistest;
}
in my view I have this:
@model IEnumerable<Models.Movie>
however, everything in this view gives an error:
Unable to create a constant value of type 'Models.Movie'. Only primitive types or enumeration types are supported in this context.
I understand the error, but how to deal with it?
Basically I am returning a list, and I am using Ienumerable
, what to do?
my view is just a foreach
loop output the fields names.
both movie and items use the same db model from Movies.
this below gives me an error:
Object reference not set to an instance of an object.
if (!String.IsNullOrEmpty(searchString))
{
thistest = thistest.Where(s => s.description.Contains(searchString)
|| s.title.Contains(searchString)
|| s.location.Contains(searchString));
}