Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

.net entity framework core public beta

user5716448Apr 24 2019 — edited Apr 29 2019

Hi,

Using tutorial to look to build a .net core crud usinfg oracle

Have followed the steps at https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/?view=aspnetcore-2.2 and wokr so.k with local sql server database.

However, want  to use oracle database as source

Have tried putting below in the context.cs and chnaged the usesqlserver to use oracle in the startup.cs

services.AddDbContext<RazorPagesMultipleContext>(options =>

                 //  options.UseSqlServer(Configuration.GetConnectionString("RazorPagesContext")));

                   options.UseOracle(Configuration.GetConnectionString("RazorPagesContext")));

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

        {

            optionsBuilder.UseOracle(@"User Id = <userid>; Password = <pwd>; Data Source = <server>:1521/<SID>;");

        }

but get message below

Severity Code Description Project File Line Suppression State

Error CS0121 The call is ambiguous between the following methods or properties: 'Microsoft.EntityFrameworkCore.OracleDbContextOptionsExtensions.UseOracle(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder, string, System.Action<Oracle.EntityFrameworkCore.Infrastructure.OracleDbContextOptionsBuilder>)' and 'Microsoft.EntityFrameworkCore.OracleDbContextOptionsBuilderExtensions.UseOracle(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder, string, System.Action<Devart.Data.Oracle.Entity.OracleDbContextOptionsBuilder>)' RazorPages D:\razorpages\RazorPages\RazorPages\Data\RazorPagesContext.cs 35 Active

Looking at

https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/sql?view=aspnetcore-2.2&tabs=visual-studio suggest can put connection string in the appsettings.json file

shows sqlserver example

RazorPagesMovieContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesMovieContext-1234;Trusted_Connection=True;MultipleActiveResultSets=true"

How can we change this to use Oracle and what is causing ambiguity above?  Have

using Oracle.EntityFrameworkCore;

using Microsoft.EntityFrameworkCore; included in startup.cs and imported the ef core beta 3 for oracle ef core and 

looking ideally to get above working with oracle and any other examples of standard guid cru with ef core and oracle.

Thanks

Comments

Stijn Gabriels
Hi Andy,

first of all, I don't really understand your SQL query. Nevertheless, I am wondering why you have used Row-Wise Initialization for this session variable, if you only want value "ALL" or the name of the region for the TEST session variable.

Regards,
Stijn
ADB
Stijn

in case a user has 'all' regions dedicated, I want to see all the organisations otherwise I only want to see the organisations linked to the specific region.

As I can't use a 'LIKE' (see error that you can only use =) into the session variable, I've worked something out returning the column name (user has 1 region) or 1 (user has all regions).

I hope it's more clear now.

KR,
A
Stijn Gabriels
So a user is joined to one or all regions and an organizations is joined to a region. Why don't you create one query, in which you join all the required tables?

Regards,
Stijn
ADB
[nQSError: 10058] A general error has occurred. [nQSError: 42040] The session variable, NQ_SESSION.ORGANISATIE, is defined as Row-Wise Initialization. It is restricted to usage with equality comparisons. (HY000)

I transformed my query like this, I don't have any clue why this isn't working...if I run this sql statement it works perfect but not in OBi

select 'ORGANISATIE', organisatie_nummer
from st_organisatie
,(select gebruiker,regio from st_gebruikers) b
where case when b.regio = -1 then 1 else regio_nummer end
like
case when b.regio = -1 then '%' else b.regio end
and upper(gebruiker) = upper(':USER')
ADB
Even after trying to create a view of the query and using this view within my session variable i have the same error.

My query is
select 'PARAM', organisatienummer
from vw_org
where upper(gebruiker) = upper(':USER')

It makes me desperate, so all help is welcome!

Kr,
A
Stijn Gabriels
I think your query should look like this:

SELECT 'ORGANISATIE', o.organisatie_nummer
FROM st_organisatie o, st_gebruikers g
WHERE o.regio_nummer = g.regio_nummer AND g.gebruiker = 'UPPER(VALUEOF(NQ_SESSION.USER))'

Regards, Stijn
ADB
:-) I know it should look like that, but that's the problem.

I don't have organisation for id = -1, that's why a make a translation of it towards a %

And even whenI put my values into a table I receive this error.....I'm lost...

Edited by: ADB on Dec 10, 2008 8:38 AM
Kishore Guggilla
Hi...

For your view approach post..
As per my knowledge... USER is the keyword for ORACLE, so it will n't accept it as bind variable.. as you are using...
So try give other name..

Thanks & Regards
Kishore Guggilla
ADB
Hi kishore,

txs but as I have the same prob when using a table, I guess there's something else;

Also when using valueof(nqsession.user) i have probs :-(
Kishore Guggilla
hi....

I am not sure this.. but try using content filter of particular logical table source...

Thanks & Regards
Kishore Guggilla
Stijn Gabriels
In my opinion this is not an OBIEE problem but a SQL / data problem.
I would advise you to fill your regio table with all correct combinations of regio and gebruiker and create the query as mentioned before.

Regards,
Stijn
1 - 11

Post Details

Added on Apr 24 2019
10 comments
1,412 views