Cannot implicitly convert type 'string' to 'System.Collections.Generic.ICollection<WebApplication2.Entry>'

StackOverflow https://stackoverflow.com/questions/17649168

Pregunta

I used ado.net entity framework to connect database and have an .edmx file in project.. When I tried to reach objects in code side with object initializer I can see the object names but when I tried to enter a value into textarea in throws this error.Title is a table in database and entries is another tables data but because of both tables has relationship I can see Entries down of Title. What do I have to do? I do not understand anything.. thanks for helps here is the situation

Title a = new Title 
{ 
 Entries=textarea.InnerText,
};
¿Fue útil?

Solución

Try below, you need to inititialize entry collection with your item by giving correct property value

Title a = new Title 
{ 
 Entries= new List<Entry>()
    {
      new  Entry() {PropertyName =textarea.InnerText}
    };
};

Otros consejos

It's because your Entrires are of type ICollection<Entry> and you trying to store there string variable.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top