The example in the link produces the following SQL with ObjectContext, or with DbContext without fluent mapping:
Code: Select all
DECLARE
updatedRowid ROWID;
BEGIN
INSERT INTO INFO.PRODUCTS("Id", "FunctionGeneratedValue", "ProductName", "Price", "ModifiedBy", "LastModified")
VALUES (MY_SEQUENCE.NEXTVAL, MY_FUNCTION(), :p0, :p1, USER, current_timestamp)
RETURNING ROWID INTO updatedRowid;
OPEN :outParameter FOR SELECT "Id", "FunctionGeneratedValue" FROM INFO.PRODUCTS WHERE ROWID = updatedRowid;
END;
Code: Select all
DECLARE
updatedRowid ROWID;
BEGIN
INSERT INTO INFO.PRODUCTS("ProductName", "Price")
VALUES (:p0, :p1)
RETURNING ROWID INTO updatedRowid;
OPEN :outParameter FOR SELECT "Id", "FunctionGeneratedValue", "ModifiedBy", "LastModified" FROM INFO.PRODUCTS WHERE ROWID = updatedRowid;
END;
Here's the (auto-generated) fluent mapping code I'm using:
Code: Select all
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
#region Products
modelBuilder.Entity()
.HasKey(p => new { p.Id })
.ToTable("PRODUCTS", "INFO");
// Properties:
modelBuilder.Entity()
.Property(p => p.Id)
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity()
.Property(p => p.ProductName)
.IsRequired()
.HasMaxLength(160)
.IsUnicode(false);
modelBuilder.Entity()
.Property(p => p.Price);
modelBuilder.Entity()
.Property(p => p.FunctionGeneratedValue)
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
modelBuilder.Entity()
.Property(p => p.ModifiedBy)
.IsRequired()
.HasMaxLength(30)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)
.IsUnicode(false);
modelBuilder.Entity()
.Property(p => p.LastModified)
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed);
#endregion
#region Disabled conventions
modelBuilder.Conventions.Remove();
modelBuilder.Conventions.Remove();
#endregion
}