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

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

문제

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,
};
도움이 되었습니까?

해결책

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}
    };
};

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top