Hi All,
I am trying to turn some function I created in an mvc application and place them into a class Library a the computer is not having it... let me demonstrate.
This is the Error I get
Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'System.Collections.Generic.List<DSDB_LIBRARY.Models.DSDB_STORE_TBL>' to 'System.Collections.Generic.List<string>' DSDB_LIBRARY C:\APP_DEV\DSDB_LIBRARY\DSDB_LIBRARY\DBDS_ClassV1.cs 178 Active
I am not sure what this error means as it does not provide any information on how one would go about fixing it.
I have another program where I made it to a list but the EF linq statement is different I will post the source codes at the bottom show that the ToList will work but it required a different ling statement but I don't get why
My MVC function looks like this , This sends in a ID and returns all rows that have the code in the DOC_SOURCE__DIS field. So If I have 20 rows it returns that the view
[HttpPost]
public ActionResult Gate(string DocCode)
{
DSDBEntities DB_Entities = new DSDBEntities();
var DocList = DB_Entities.DSDB_STORE_TBL.Where(d => d.DOC_SOURCE_DISC == DocCode).ToList();
return View(DocList);
}
Here is my attempt to make it work in the class library. I would like the same thing to happen in this calls library if possible The User sends in the code DocCode the system gets the information from the database allowing me to pass it back as something I can use in a mvc program or a webforms program or what ever I may need. I could not find anything online that would help some hopefully some one here can help. Thanks so very much.
public List<string> GET_DOCUMENTS_BY_DocCode(string DocCode)
{
DSDB_CLASS_Entities db = new DSDB_CLASS_Entities();
var DocList = db.DSDB_STORE_TBL.Where(d => d.DOC_SOURCE_DISC == DocCode).ToList();
return DocList;
}
Error
THe Error is :
Severity Code Description Project File Line Suppression State
Error CS0029 Cannot implicitly convert type 'System.Collections.Generic.List<DSDB_LIBRARY.Models.DSDB_STORE_TBL>' to 'System.Collections.Generic.List<string>' DSDB_LIBRARY C:\APP_DEV\DSDB_LIBRARY\DSDB_LIBRARY\DBDS_ClassV1.cs 178 Active
This tolist worked, its stuff like this where there is an error that blows my mind. So any help that anyone can provide I would be grateful as I am trying to understand what is going on here.
public List<string> GetStaffEmail(string PositID)
{
//CONVERTING THE POSIT BECAUSE IT WAS ORGINALLY A STRING IN THE OTHER TABLE
var StaffEmailList = FMSdb.VUE_RVRS_EMPLOYEE_POSIT.Where(p => p.Manager_ID == Convert.ToInt16(PositID)).Select(p => p.Email).ToList();
return StaffEmailList;
}