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 make better use of ADO.NET access Technology

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to make better use of ADO.NET access technology. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

This is our .NET support. Our direction is to provide a comprehensive functional access. So the answer to your question is yes. We will support .NET according to the needs of our users, and take a look at all the content provided by the Windows Development Center on the Oracle technology website. ADO.NET is very proactive in visiting us.

If you only retrieve the data and do not need to update the data, you can cancel change tracking by using MergeOption.NoTracking. In this way, ObjectStateManager will not be used, reducing the time it takes to execute the query, and all returned entities will be in a separate state (detached state). NoTracking is a better choice when displaying data as read-only in ASP.NET web application or in WinForms / WPF Grids controls.

When using object Services (Object Services) and ADO.NET access, you need to call an overloaded constructor of ObjectQuery, where the third parameter is the MergeOption enumeration. The default behavior is AppendOnly, which can be changed to NoTracking.

Product product1 = context.Product.FirstOrDefault (p = > p.ProductID = = 1004); if (product1! = null) {product1.Color = "Black"; product1.StandardCost = 20; product1.ListPrice = 25;} var objectStateEntries = context.ObjectStateManager.GetObjectStateEntries (EntityState.Modified) Foreach (var entry in objectStateEntries) {Console.WriteLine ("{0}-{1}-{2}", entry.EntityKey.EntityContainerName, entry.EntityKey.EntitySetName.ToString (), entry.EntityKey.EntityKeyValues.First (). Key + "=" + entry.EntityKey.EntityKeyValues.First () .value); for (int I = 0; I

< entry.OriginalValues.FieldCount; i++) { Console.WriteLine("\t {0} ->

{1} ", entry.OriginalValues [I], entry.CurrentValues [I]);}}

In the following example, you first retrieve a specific Product record, modify three of its properties, call the GetObjectStateEntries (EntityState.Modified) method, return a list of all updated entities, and further iterate through the ObjectStateEntry collection, showing the entity name, ADO.NET access, initial value, and current value.

This is the end of this article on "how to make better use of ADO.NET access technology". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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