OData / AspNetCoreOData

ASP.NET Core OData: A server library built upon ODataLib and ASP.NET Core
Other
454 stars 160 forks source link

LINQ2DB support #547

Open aboryczko opened 2 years ago

aboryczko commented 2 years ago

Hi, Would it be possible to improve LINQ2DB support? I've noticed that most of my problems came from null propagation handling. The HandleNullPropagationOptionHelper has some hardcoded namespaces for Microsoft DB libraries, are there some special conditions that need to be met to "certify" LINQ2DB to add it there? I feel that a lot of people that have tried LINQ2DB were unable to get to the bottom of why they received errors. I know that the workaround is to set [EnableQuery(HandleNullPropagation = HandleNullPropagationOption.False)], but it's not easy to find.

julealgon commented 2 years ago

Asking for support for "library X" seems like the wrong way to go about this. Wouldn't it be best to "make it provider-agnostic" instead, working only with the IQueryable interface?

aboryczko commented 2 years ago

It would be nice, but I imagine that would take a lot of effort. I'd be OK with something as simple as adding an option in Startup that makes provider X handle null propagation as I see fit.

gathogojr commented 2 years ago

@aboryczko We can look at improving the error message if we're able to identify this error case. We can also see about making it possible to configure the HandleNullPropagation setting from Startup. We welcome pull request contribution if you're in a position to contribute

aboryczko commented 2 years ago

@gathogojr as far as I understand the idea is that the in-memory provider needs to have null handling done by the library, but the database ones usually do it on their own and setting this globaly might break it if someone exposes an in-memory IQueryable. Doing a hard default during startup would break this, right? If this is not the case I could do something simple within DefaultQuerySettings to set this.