*Q: PackageMigrations - Updating & Inserting Recor...
# package-development
w
Q: PackageMigrations - Updating & Inserting Records etc.. Is there benefit of just using
Database.Execute("RAW SQL string")
or should the expression approach be used instead or...?!
Copy code
csharp
 Insert.IntoTable(Data.Constants.TableName.MyTable)
            .EnableIdentityInsert()
            .Row(new
            {
                someId = 1001,
                type = "WARREN",
                isDisabled = false
            })
            .Do();
Any thoughts @Ronald Barendse ?
Or a third way of using
Database.Insert()
with the POCO
r
Well, the benefit of not using raw SQL is that you can use typed objects and the database provider can produce the correct parameterized SQL statements 😄 And for package migrations, using a POCO might be fine too, because it doesn't really matter when the POCO changes, as the current state is ignored and all migrations are always executed. For normal migrations though, changes to the POCO might alter the migration (and potentially break/cause data corruption).
w
Thanks for the feedback. So I will go with using the Expression Builders then !!