protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var isDateMethodInfo = typeof(UDFSqlContext).GetMethod(nameof(IsDateStatic));

            modelBuilder.HasDbFunction(isDateMethodInfo)
            .HasTranslation(args => new SqlFunctionExpression(null, "IsDate", args, true, new[] { true }, isDateMethodInfo.ReturnType, null));
            var isDateMethodInfo2 = typeof(UDFSqlContext).GetMethod(nameof(IsDateInstance));

            modelBuilder.HasDbFunction(isDateMethodInfo2)
            .HasTranslation(args => new SqlFunctionExpression(null, "IsDate", args, true, new[] { true }, isDateMethodInfo2.ReturnType, null));

            var methodInfo = typeof(UDFSqlContext).GetMethod(nameof(MyCustomLengthStatic));

            modelBuilder.HasDbFunction(methodInfo)
            .HasTranslation(args => new SqlFunctionExpression("char_length", args, true, new[] { true }, methodInfo.ReturnType, null));
            var methodInfo2 = typeof(UDFSqlContext).GetMethod(nameof(MyCustomLengthInstance));

            modelBuilder.HasDbFunction(methodInfo2)
            .HasTranslation(args => new SqlFunctionExpression("char_length", args, true, new[] { true }, methodInfo2.ReturnType, null));
            var methodInfo3 = typeof(UDFSqlContext).GetMethod(nameof(StringLength));

            modelBuilder.HasDbFunction(methodInfo3)
            .HasTranslation(args => new SqlFunctionExpression("char_length", args, true, new[] { true }, methodInfo3.ReturnType, null));

            modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetCustomerWithMostOrdersAfterDateStatic)))
            .HasName("GetCustWithMostOrdersAfterDate");
            modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetCustomerWithMostOrdersAfterDateInstance)))
            .HasName("GetCustWithMostOrdersAfterDate");

            modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(IdentityString)))
            .HasSchema(null);

            ModelHelpers.SetPrimaryKeyGeneration(modelBuilder);
        }
示例#2
0
 protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
 {
     base.OnModelCreating(modelBuilder, context);
     ModelHelpers.SetPrimaryKeyGeneration(modelBuilder);
     ModelHelpers.SimpleTableNames(modelBuilder);
 }
示例#3
0
 protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
 {
     base.OnModelCreating(modelBuilder, context);
     ModelHelpers.SetPrimaryKeyGeneration(modelBuilder, context);
     ModelHelpers.SetStringLengths(modelBuilder, context);
 }
示例#4
0
 protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
 {
     base.OnModelCreating(modelBuilder, context);
     ModelHelpers.SimpleTableNames(modelBuilder);
     ModelHelpers.SetPrimaryKeyGeneration(modelBuilder, FbValueGenerationStrategy.IdentityColumn);
 }