Esempio n. 1
0
        public void delete_with_schema_both_from_fluent_API_and_data_annotation()
        {
            using (var db = new FluentApiDataAnnotationContext("someApiSchema"))
            {
                var sql = db.Products
                          .Where(x => x.Id == 1)
                          .GenerateBulkDeleteSql();

                // Fluent API takes precedence over data annotation
                Assert.Equal(@"DELETE FROM [someApiSchema].[Products]
WHERE [Products].[Id] = 1;", sql, false, true, false);
            }
        }
Esempio n. 2
0
        public void update_with_schema_both_from_fluent_API_and_data_annotation()
        {
            using (var db = new FluentApiDataAnnotationContext("someApiSchema"))
            {
                var sql = db.Products
                          .Where(x => x.Id == 1)
                          .SetField(x => x.Name).WithValue("some name")
                          .SetField(x => x.Description).WithValue("some description")
                          .GenerateBulkUpdateSql();

                // Fluent API takes precedence over data annotation
                Assert.Equal(@"UPDATE [someApiSchema].[Products]
SET [Products].[Name] = {0}, 
    [Products].[Description] = {1}
WHERE [Products].[Id] = 1;", sql, false, true, false);
            }
        }