dataobjects-net icon indicating copy to clipboard operation
dataobjects-net copied to clipboard

Use additional information about parameter values on DbParameter creation

Open alex-kulakov opened this issue 4 years ago • 0 comments

Some additional information would be helpful on DbParameter creation. For instance, precision and scale for decimals or length for strings.

For example, for the following model

     [HierarchyRoot]
     public class Author : Entity
     {
       [Key]
       [Field]
       public int Id { get; private set; }

       [Field(Precision = 9, Scale = 3)]
       public decimal Test { get; set; }

       public Author(Session session): base(session) 
       {
       }
     }

setting the precision and scale from field instead of actual value of Test on persist operations will be beneficial for query plan cache. As an example, updating the Test field value. We always have the same query except for the parameter's value. But due to different precision and scale some queries are treated as "different"(but they are not).

We have ParameterBinding and it may be a great way to pass this additional info.

For persist operations (INSERT, UPDATE, DELETE) such bindings are created in PersistRequestBuilder and all needed information about fields and columns is available there.

For queries it will be more complicated. Need to investigate what cases can pass information about parameters.

We will be able to use the info in CommandFactory to initialize DbParameter properties, and in case of no additional information we let RDBMS driver decide (current behavior).

alex-kulakov avatar Aug 20 '20 08:08 alex-kulakov