In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to save data with ServiceStack's OrmLite". In daily operation, I believe many people have doubts about how to use ServiceStack's OrmLite to save data. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to save data with ServiceStack's OrmLite". Next, please follow the editor to study!
ServiceStack:OrmLite operates the database
When OrmLite saves data, it is required that in the development, the model class name, field name and the corresponding table and field name in the database should be consistent, so that they can be written into the database. This is the beginning of use, but lack of experience. Later, I looked up the official document and found that by assigning attributes to the table name and attribute name, I was able to correspond with the database.
When using model, the sources of obtaining data may be different. For example, the data fields obtained from the json data of the network service are inconsistent with the fields of the existing tables in the database. Of course, two model can be defined for exchange, which will have a lot of code redundancy and involve the conversion of data in model.
Therefore, ServiceStack's OrmLite provides the conversion of fields by marking properties, the most common of which are the following two:
Alias corresponds the current attribute to the name of the field in the table in the database, or it can correspond to the table name.
[Alias ("stationid")]
Public string StationID {get; set;}
Ignore is an ignored field, and this attribute will not correspond to the field in the data table, because if the data table does not have this attribute, if it is not added, an error will be reported.
[Ignore]
Public string StationName {get; set;}
By setting it up in model, you can save the data returned from other sources directly to the database using the Save function.
There are other attribute controls in OrmLite, such as field length, which can be viewed by referring to the official website.
At this point, the study on "how to save data with ServiceStack OrmLite" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.