how can i use a defined function in my database with entity framework core?

.net-core asp.net-core entity-framework-core

Question

I want to use entity framework core to get data from database instead of using sql request like in this exemple : SELECT INT_To_STR(CODE), LIBELLE FROM TABLE2 will be replaced by :

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseOracle(ConnectionString);
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Ccy>(entity =>
        {
            entity.ToTable("Table2");
            entity.HasKey(e => e.Code);
            entity.Property(e => e.Code).HasColumnName("CODE");
            entity.Property(e => e.Name).HasColumnName("LIBELLE");
        });
    }

the problem that i am facing is that i want to use the function 'INT_To_STR' Is there any solution? Thanks.

1
1
7/24/2018 12:21:17 PM

Popular Answer

Please have a look on query types. With their help you can call user-defined functions in your database like this:

context.[QUERYTYPE].FromSql("SELECT [FUNCTIONNAME] ...")
0
7/24/2018 1:22:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow