EF has some problems.

Source: Internet
Author: User

EF has some problems.

Environment: EntityFramework version: 4.1.0.0

 

Question 1: "data reader and specified"..." Incompatible. A type is "..." .".

Usage: rep. context. Database. SqlQuery <T> (SQL, pList. ToArray <object> (); // SQL concatenates strings directly.

Cause: T is a view, because the fields in the database have the prefix "C _", and we performed the prefix operation when producing the object. As a result, the field does not match.

Solution: When spelling an SQL string, remove the prefix field from the alias. For example, C_DISP_TYPE_NM as DISP_TYPE_NM.

 

Problem 2: The "MAIN_STAT" attribute of "V_CLAIM_DISPATCH" cannot be set to "Int64. You must set this attribute to a non-null value of the type "Int32"

Usage: var surveyList = claimBiz. FindAll <V_CLAIM_DISPATCH> (sqlText, pList );

Cause: [UNKNOWN] the possible cause is that the database is number (10) and the generated entity is int. The actually read data corresponds to int64. However, the EF ing of that field type is automatically completed by EF and cannot be manually modified. So an error is reported.

Solution: write a new class V_CLAIM_DISPATCH_COPY flag field Nullable <Int64> MAIN_STAT. In the above method, var surveyList = claimBiz. FindAll <V_CLAIM_DISPATCH_COPY> (sqlText, pList); change the generic type to a custom class.

 

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.