What is the higher performance of accessing Typed Dataset than that of untyped dataset?

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.