Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Udt using EntityFramework core #190

Open
Regenhardt opened this issue Aug 25, 2021 · 6 comments
Open

Udt using EntityFramework core #190

Regenhardt opened this issue Aug 25, 2021 · 6 comments

Comments

@Regenhardt
Copy link

Now that #56 is done, can we get UDT support in Oracle.EntityFrameworkCore too?
Would be nice to just

entity.Property(e => e.ComplexValue).HasColumnType("ComplexType").HasColumnName("ComplexValue")

and map it to a C# class.

@alexkeh
Copy link
Member

alexkeh commented Aug 25, 2021

@Regenhardt Are you looking for an ODP.NET NetTopologySuite implementation or something more native to Oracle UDTs?

Or are you looking for some tooling to auto-generate the custom UDT C# class as the Oracle Developer Tools for Visual Studio does for unmanaged ODP.NET?

@Regenhardt
Copy link
Author

I'm looking for a way of working with UDTs in an oracle database using entity framework core. Couldn't find an example for that, and I haven't read anything about that in #56, so I'm assuming it isn't implemented yet. I'd gladly be proven wrong by a simple example for how to map a UDT using EF though :-)

Minimally, I'm still trying to get this setup working: https://stackoverflow.com/questions/68007637/map-efcore-to-oracle-custom-composite-type

@alexkeh
Copy link
Member

alexkeh commented Aug 26, 2021

That's correct. It's not been implemented yet. The question becomes how to manifest UDT data that works for most EF Core data. If the use case is primarily spatial data, then ODP.NET supporting NetTopologySuite in EF Core may be the easiest.

If it's generic UDTs, then some more investigation needs to occur. It may not be possible to make generic UDT functionality to be available in EF Core until the provider model allows it.

I do encourage anyone interested in this functionality to vote with a thumbs up for this feature and to be specific exactly what UDT features they need so that my team can scope the features developers want the most.

@Regenhardt
Copy link
Author

Since I'm not entirely sure what different features there are in the topic UDT, I'll try to describe a minimal use case I'd like to see implemented in the EFcore provider:

I have a custom type in the database:

CREATE TYPE STAMP( 
    timestamp DATE, 
    num INTEGER 
)

Then have a table:

CREATE TABLE LOGS(
  event nvarchar(100),
  from STAMP,
  to STAMP
)

Now in SQL I can read a log like this:

SELECT event, FROM LOGS
WHERE (from).timestamp between date'2021-06-07' AND date'2021-06-09'

In C#, the model I'd want this to be mapped to would be this, annotated for the custom type:

[CustomType("STAMP")]
public class Stamp
{
  [CustomField("event")] // Or just [Field]? Or does something already exist that makes sense to be reused like [Column]?
  public string Event { get; set; }
  [CustomField("timestamp")] // Or let it automap if case-insensitive mapping works and throw otherwise?
  public DateTime Timestamp { get; set; }
  [CustomField("num")]
  public int Num { get; set; }
}

So then i can go

return await entities.Logs.where(log =>  
    log.From.TimeStamp > new DateTime(2021,6,7) && log.From.TimeStamp < new DateTime(2021,6,9)).ToListAsync();

@nikjw-lmk
Copy link

Just to add my interest. I would be interested in an ODP.NET NetTopologySuite implementation. Like the ones you see for Postgresql and Sql Server. Thanks

@gscpw
Copy link

gscpw commented Nov 2, 2023

Spatial support has been requested in #89, but the issue has been closed with simple isn't implemented response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants