I have seen many such comments on the Internet,AccessThe performance of Typed Dataset data is higher than that of untyped dataset. I have always been skeptical. After all, both are implemented based on DataSet. The former isCodeDetermine the structure when writing. The latter is determined at runtime. The efficiency of the two operations after instantiation is the same.
But fromHttp://rottenapple.cnblogs.com/when the test result is displayed, the value of the datarow field of index untyped dataset is not as fast as that of the typed dataset! Is there anything faster than index positioning? So I will see how the typed dataset access Member values are defined.
The Code is as follows:
Public IntCategoryid
{
Get{
Return((Int)(This[This. Tablecategories. categoryidcolumn]);
}
Set{
This[This. Tablecategories. categoryidcolumn] =Value;
}
}
OriginalIn addition to key and index, datarow also provides the datacolumn locating method. Why is positioning faster than index through datacolumn? To find this cause, you can only use the decompilation to check the datarow code.
The following code is finally displayed after decompilation.
Public object this [int columnindex]
{
Get
{
Return [Table. Columns [columnindex];
}
Set
{
[Table. Columns [columnindex] = value;
}
}
Whether you are usingIn the end, both the key and index positioning are used to locate the final visitor through datacolumn. ActuallyThe access efficiency of typed dataset or untyped dataset should be the same, but the access efficiency may vary due to different access methods.
Developers can writeTyped Dataset is repackaged to define the data access method. It is not so convenient for untyped dataset, because keys can only be used for convenient use and maintenance during the runtime. Although Typed Dataset improves access efficiency (I think it is only a small improvement), it also brings about maintenance work for typed dataset.
If efficiency is really required, why not use it directly?What about datareader? The method I prefer to use is datareader-> entity. The above is my personal opinion.