c# - How to fill a custom typed List<> from SQL Server -
i have class named author.cs
defined as:
public class author : interfaces.inode { private list<inode> _targetlist; private list<iattribute> _attributeobject; // author class constructor public author() { _targetlist = new list<inode>(); } //implementazion of _targetobject inode method public list<inode> _targetobject { { return _targetlist; } } //implementazion of _attributeobject inode method public list<iattribute> _attributeobject { { return _attributeobject; } } public int _aid { get; set; } public string _aname { get; set; } // 'coauthor', 'venue' , 'paper' classes // implements interface i.e. `iattribute` public list<coauthor> _acoauthors { get; set; } public list<venue> _avenue { get; set; } public list<paper> _apapers { get; set; } public string _aarea { get; set; } }
which implements interface in interfaces
folder named interfaces.inode.cs
defined as:
public interface inode { list<inode> _targetobject { get; } list<iattribute> _attributeobject { get; } } public interface iattribute : inode {}
now want fill list i.e. list<author>
i.e. in class named authorcollector.cs
list<author> _eathors = new list<author>();
i have tried as:
try { sqlcommand _mycommand_1 = _con.createcommand(); _mycommand_1.commandtext = @"select author_id m_datafull order author_id, year"; var _authid = 0; int _row_counter = 0; using (sqldatareader _myreader_1 = _mycommand_1.executereader()) { while (_myreader_1.read()) { _row_counter++; _eathors.add(convert.toint32(_myreader_1["author_id"])); } _myreader_1.close(); } } catch(exception e) { console.writeline(e.message); }
the error is:
the best overloaded method match _eauthors.add()
has invalid arguments.
please in regard.
using (sqldatareader _myreader_1 = _mycommand_1.executereader()) { while (_myreader_1.read()) { _row_counter++; author author = new author(); author._aid = convert.toint32(_myreader_1["author_id"]); author._aname = convert.tostring(_myreader_1["author_name"]); //etc... _eathors.add(author); } _myreader_1.close(); }
Comments
Post a Comment