0

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,
};
regeme
  • 872
  • 6
  • 17
  • 30

2 Answers2

0

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

Oleksii Aza
  • 5,368
  • 28
  • 35
  • and so? what kind of conversion do I have to do? Yes I want to store InnerText in db it has related field there.. I want to store it in Entry table it is a seperate table. when I entered title from related texbox and stored in db, isnt that possible to reach also the data that has relation with another table and store the InnerText like that? do I have to do it seperately for all objects? – regeme Jul 15 '13 at 08:00
0

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}
    };
};
Damith
  • 62,401
  • 13
  • 102
  • 153
  • also do you have any idea that display those on different texboxes? when I clicked title from listbox an entry related to that has to be appeared another listbox and this has to be change dynamically when I clicked title but it seems not.. just titles listed in a listbox the entry not diplayed I've checked from db that entry stored but not displayed as I've sad.I know this is too long but If you can help you will save my life – regeme Jul 15 '13 at 08:18
  • stackoverflow is not like forum, you need to ask seperate question with related code which you already try so far and also details of problem. it is not clear what exactly you want to do, you may need to write the display item logic in the listbox selected item change event. – Damith Jul 15 '13 at 08:26
  • It's just one step away of my problem I don't want to waste another topıc for related problem if I did I have to repeat the same question above again to make clear the other question. No intention to make here forum, just to inform you .. anyway thanks – regeme Jul 15 '13 at 08:40