I am creating an .edmx into my MVC project. I have mapped two procedures that returns movies information from database.
The first procedure, which is getMoviesByName, returns only Id and Name. The second procedure, which is getAllMovies, returns Id, Name and CreatedDate.
I would like to both procedures to returns data as a ComplexType called Movie.
I am instantiating my MyDbEntities and trying to use both procedures according to a condition just like in the example below but it fails when variable isLookingByName
is true with the following message:
A member of the type, 'CreatedDate', does not have a corresponding column in the data reader with the same name.
Example:
var db = new MyDbEntities();
if(isLookingByName)
{
return db.getMoviesByName(name).ToList();
}
return db.getAllMovies().ToList();
So whenever the condition is true it throws that exception. The thing is that I cant change the first procedure to add CreatedDate
.
Just to let you guys know in my View I display all those three information Id, Name and CreatedDate. When CreatedDate is null it is not displayed and I am fine with that.
Someone knows how should I proceed?
Thank you very much!