c# - EDMX database mapping two procedures to the same ComplexType -


i creating .edmx mvc project. have mapped 2 procedures returns movies information database.

the first procedure, getmoviesbyname, returns id , name. second procedure, getallmovies, returns id, name , createddate.

i both procedures returns data complextype called movie.

i instantiating mydbentities , trying use both procedures according condition in example below fails when variable islookingbyname true following message:

a member of type, 'createddate', not have corresponding column in data reader same name.

example:

var db = new mydbentities(); if(islookingbyname)  {      return db.getmoviesbyname(name).tolist(); }  return db.getallmovies().tolist(); 

so whenever condition true throws exception. thing cant change first procedure add createddate.

just let guys know in view display 3 information id, name , createddate. when createddate null not displayed , fine that.

someone knows how should proceed?

thank much!

the workaround use ado.net

using (sqlconnection connection = new sqlconnection(connectionstring)) {     connection.open();      using (sqlcommand command = new sqlcommand(     "select id, name , createddate  movies id= @id", connection))     {          command.parameters.add(new sqlparameter("@id", id));          sqldatareader reader = command.executereader();         if(reader.hasrows())         {             var id= reader["id"].tostring();             var name= reader["name"].tostring();         }     } } 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -