Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of LINQ Mapping Database

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to solve the problem of LINQ mapping database". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to solve the problem of LINQ mapping database.

LINQ mapping database

Data types such as private System.Nullable often appear in Linq mapping database files, but it is not clear to those who have just come into contact with. Here, it is mapped according to your database field. System.Nullable mapping to your database field is a field of int type of NULL. This type is in the C # syntax. When assigning a value to this field, there will be an int? When it appears, it will report a mistake, saying that it will not quote an error. This is a common problem in my project.

The common solution is

1. Modify the database field, change the int type field from null to non-empty, and give a default value. Then remap the data table to LINQ

two。 Redefine an entity class to change int? Type is cast to an int type.

The syntax operation of LinQ is delayed, and when doing transaction operation

Using (DBTablesMappingDataContext dc = new DBTablesMappingDataContext (_ connString)) {/ / any operation in this can be seen as a transaction that no longer needs to be opened as a transaction. Thank you for your reading, the above is the content of "how to solve the problem of LINQ mapping database". After the study of this article, I believe you have a deeper understanding of how to solve the problem of LINQ mapping database, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report