简体   繁体   中英

Cannot convert DataRow to titlesDataRow

I want to convert a DataRow into a titlesRow but i am having troubles to convert it, how i can do it?

private koianimeDataSet.titlesRow titlesRow;
DataTable dt = ta.GetDataByViews();
titlesRow = dt.Rows[0];

enter image description here

As I understand it: koianimeDataSet.titlesRow is the specific row subclass of a "typed dataset", ie titlesRow : DataRow . Now: if this is correct, and if GetDataByViews is making use of the typed dataset , then you should be able to just cast it:

titlesRow = (koianimeDataSet.titlesRow)dt.Rows[0];

If this works, then you should also check whether GetDataByViews could just return the typed datatable. It might actually already do this, so it could also be the case that:

var dt = ta.GetDataByViews();

fixes everything, by picking up the right table type.


If GetDataByViews doesn't make use of the typed dataset, then it will be a much bigger job. Frankly, before fixing that, I'd sooner challenge the assumption that DataSet (typed or otherwise) should be used at all here. In most ways: datasets are redundant compared to more modern class typed data access APIs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM