Here is an example of one of the ways I have tried to default the value.
Code: Select all
ALTER TABLE "SalesOrderHeader" ALTER COLUMN "CreatedDate" SET DEFAULT localtimestamp;
Code: Select all
ALTER TABLE "SalesOrderHeader" ALTER COLUMN "CreatedDate" SET DEFAULT localtimestamp;
Code: Select all
public class MvcApplication : System.Web.HttpApplication
{
PgSqlMonitor monitor;
protected void Application_Start()
{
monitor = new PgSqlMonitor() { IsActive = true };
// ....
}
}
Code: Select all
INSERT INTO public."SalesOrderHeader" ("CustomerId", "OrderNumber", "SalesRepId", "SalesRepName", "SourceCode", "Date", "SubTotal", "Discount", "SalesTaxRate", "SalesTaxAmount", "ShippingTotal", "OrderTotal", "PaymentMethodTypeId", "PromoCode", "CreatedBy", "ModifiedBy", "Exported", "Notes") VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18) RETURNING "SalesOrderHeaderId"
OutOfTouch6947 wrote:You can see that I removed the CreatedDate from the model for this table as a test to see, if it would default correctly, and it still does not, but it also is not in this insert statement.Code: Select all
INSERT INTO public."SalesOrderHeader" ("CustomerId", "OrderNumber", "SalesRepId", "SalesRepName", "SourceCode", "Date", "SubTotal", "Discount", "SalesTaxRate", "SalesTaxAmount", "ShippingTotal", "OrderTotal", "PaymentMethodTypeId", "PromoCode", "CreatedBy", "ModifiedBy", "Exported", "Notes") VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18) RETURNING "SalesOrderHeaderId"
OutOfTouch6947 wrote:Correction I now see the correct value being inserted into the table for the CreatedDate, I am going to add it back to the model and run dbmonitor again and see if it works correctly.
OutOfTouch6947 wrote:You can see that I removed the CreatedDate from the model for this table as a test to see, if it would default correctly, and it still does not, but it also is not in this insert statement.Code: Select all
INSERT INTO public."SalesOrderHeader" ("CustomerId", "OrderNumber", "SalesRepId", "SalesRepName", "SourceCode", "Date", "SubTotal", "Discount", "SalesTaxRate", "SalesTaxAmount", "ShippingTotal", "OrderTotal", "PaymentMethodTypeId", "PromoCode", "CreatedBy", "ModifiedBy", "Exported", "Notes") VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18) RETURNING "SalesOrderHeaderId"
Code: Select all
INSERT INTO public."SalesOrderHeader" ("CustomerId", "OrderNumber", "SalesRepId", "SalesRepName", "SourceCode", "Date", "SubTotal", "Discount", "SalesTaxRate", "SalesTaxAmount", "ShippingTotal", "OrderTotal", "PaymentMethodTypeId", "PromoCode", "CreatedDate", "CreatedBy", "ModifiedDate", "ModifiedBy", "Exported", "Notes") VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18, :p19, :p20) RETURNING "SalesOrderHeaderId"
OutOfTouch6947 wrote:I just added it back to the model and again I don't see the correct datetime being inserted, I am going to run DBMONITOR again and post the insert statement.OutOfTouch6947 wrote:Correction I now see the correct value being inserted into the table for the CreatedDate, I am going to add it back to the model and run dbmonitor again and see if it works correctly.
OutOfTouch6947 wrote:You can see that I removed the CreatedDate from the model for this table as a test to see, if it would default correctly, and it still does not, but it also is not in this insert statement.Code: Select all
INSERT INTO public."SalesOrderHeader" ("CustomerId", "OrderNumber", "SalesRepId", "SalesRepName", "SourceCode", "Date", "SubTotal", "Discount", "SalesTaxRate", "SalesTaxAmount", "ShippingTotal", "OrderTotal", "PaymentMethodTypeId", "PromoCode", "CreatedBy", "ModifiedBy", "Exported", "Notes") VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18) RETURNING "SalesOrderHeaderId"
1. Did you set the following attributes for your CreatedDate and ModifiedDate properties in *.lqml?OutOfTouch6947 wrote:Here is the insert statement with the CreatedDate and ModifiedDate added back into the models and the values are not defaulting correctly in the backend, so the model must be passin in some junk value. [...]
Shalex wrote:1. Did you set the following attributes for your CreatedDate and ModifiedDate properties in *.lqml?OutOfTouch6947 wrote:Here is the insert statement with the CreatedDate and ModifiedDate added back into the models and the values are not defaulting correctly in the backend, so the model must be passin in some junk value. [...]
CreatedDate: AutoGeneratedValue=True, Auto-Sync=OnInsert
ModifiedDate: AutoGeneratedValue=True, Auto-Sync=OnUpdate
2. Specify (via dbMonitor) the values of parameters used in the INSERT statement for "CreatedDate" and "ModifiedDate" columns.
3. Send us a small test project with the corresponding DDL/DML script for reproducing the issue in our environment.