Get the App
SLTechnology News&Howtos  ›  Development  › 

How to make better use of ADO.NET access Technology

Shulou Source: shulou.com Published: 2022-06-03 03:32:11 10月24日 Update

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.

Tags: Technology entity data article content more support update retrieval good practical active three function function parameter can be passed name object that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Huawei MySQL Redmi macOS