GithubHelp home page GithubHelp logo

linqpadodata4's People

Contributors

meancrazy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

linqpadodata4's Issues

Unable to create new connections with Windows Authentication

I'm unable to add a new connection pointing to an OData 4 endpoint using Windows Authentication. The driver fails with a WebException: Failed to access the metadata document.

After debugging the driver, it appears that the issue is at

var webRequest = (HttpWebRequest)WebRequest.Create(metadataUri);
. The web request is created with no credentials.

Also at

using (var reader = XmlReader.Create(metadataUri.ToString()))
, the XmlReader is created without any settings. I think it should use the constructor with the XmlReaderSettings.

Here is an example of the fix (code not tested):

var customResolver = new XmlSecureResolver(new XmlUrlResolver(), metadataUri.ToString())
{ 
    Credentials = GetCredentials(cxInfo) 
};

using (var reader = XmlReader.Create(metadataUri.ToString(), new XmlReaderSettings() { XmlResolver = customResolver }))
{

}

OData 4 and SSL Connection

When using this extension I receive an error "The SSL connection could not be established, see inner exception". We recently moved from Odata v3 to Odata v4. It worked fine with Odata v3. I can access the service in other tools like Postman without issue. Here is the exception from the LinqPad log.

6.13.13 (X64) 2021-04-27T09:29:22.3089468-04:00 Error opening DataContext
RemoteException - WebException - The SSL connection could not be established, see inner exception.
Source=OData4.LINQPadDriver

-OData4.LINQPadDriver.Templates.ODataT4CodeGenerator+CodeGenerationContext System.IO.Stream GetEdmxStreamFromUri(System.Uri, OData4.LINQPadDriver.ConnectionProperties) offset: 0x11C
-OData4.LINQPadDriver.Templates.ODataT4CodeGenerator+CodeGenerationContext System.String GetEdmxStringFromMetadataPath(System.Uri, OData4.LINQPadDriver.ConnectionProperties) offset: 0x2
-OData4.LINQPadDriver.Templates.ODataT4CodeGenerator System.String TransformText() offset: 0x63
-OData4.LINQPadDriver.DynamicDriver System.Collections.Generic.List`1[LINQPad.Extensibility.DataContext.ExplorerItem] GetSchemaAndBuildAssembly(LINQPad.Extensibility.DataContext.IConnectionInfo, System.Reflection.AssemblyName, System.String ByRef, System.String ByRef) offset: 0x43
-LINQPad.Extensibility.DataContext.DynamicDataContextDriver LINQPad.Extensibility.DataContext.DynamicSchemaResult GetSchemaAndBuildAssemblyInternal(System.String, System.String) offset: 0x28

INNER: HttpRequestException - The SSL connection could not be established, see inner exception.
Source=System.Net.Http

-System.Net.Http.ConnectHelper+<EstablishSslConnectionAsyncCore>d__4 Void MoveNext() offset: 0x138
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter TResult GetResult() offset: 0x0
-System.Net.Http.HttpConnectionPool+<ConnectAsync>d__82 Void MoveNext() offset: 0x344
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Runtime.CompilerServices.TaskAwaiter Void ValidateEnd(System.Threading.Tasks.Task) offset: 0x8
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter TResult GetResult() offset: 0x0
-System.Net.Http.HttpConnectionPool+<CreateHttp11ConnectionAsync>d__86 Void MoveNext() offset: 0x8F
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Runtime.CompilerServices.TaskAwaiter Void ValidateEnd(System.Threading.Tasks.Task) offset: 0x8
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter TResult GetResult() offset: 0x0
-System.Net.Http.HttpConnectionPool+<GetHttpConnectionAsync>d__67 Void MoveNext() offset: 0x13E
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Runtime.CompilerServices.TaskAwaiter Void ValidateEnd(System.Threading.Tasks.Task) offset: 0x8
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter TResult GetResult() offset: 0x0
-System.Net.Http.HttpConnectionPool+<SendWithRetryAsync>d__72 Void MoveNext() offset: 0x91
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter TResult GetResult() offset: 0x0
-System.Net.Http.RedirectHandler+<SendAsync>d__4 Void MoveNext() offset: 0x94
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ValueTaskAwaiter`1 TResult GetResult() offset: 0x0
-System.Net.Http.HttpMessageHandlerStage System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) offset: 0x12
-System.Net.Http.SocketsHttpHandler System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) offset: 0x84
-System.Net.Http.HttpClientHandler System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) offset: 0xF
-System.Net.Http.HttpMessageInvoker System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) offset: 0x6B
-System.Net.Http.HttpClient+<SendAsyncCore>d__85 Void MoveNext() offset: 0x14B
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Threading.Tasks.ValueTask`1 TResult get_Result() offset: 0x1B
-System.Runtime.CompilerServices.ValueTaskAwaiter`1 TResult GetResult() offset: 0x0
-System.Net.Http.HttpClient System.Net.Http.HttpResponseMessage Send(System.Net.Http.HttpRequestMessage, System.Net.Http.HttpCompletionOption, System.Threading.CancellationToken) offset: 0x1B
-System.Net.HttpWebRequest+<SendRequest>d__196 Void MoveNext() offset: 0x1A8
-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Runtime.CompilerServices.TaskAwaiter`1 TResult GetResult() offset: 0x0
-System.Net.HttpWebRequest System.Net.WebResponse GetResponse() offset: 0x18


  INNER: AuthenticationException - The remote certificate was rejected by the provided RemoteCertificateValidationCallback.
  Source=System.Private.CoreLib
  
   -System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
   -System.Net.Security.SslStream Void SendAuthResetSignal(System.Net.Security.ProtocolToken, System.Runtime.ExceptionServices.ExceptionDispatchInfo) offset: 0x35
   -System.Net.Security.SslStream+<ForceAuthenticationAsync>d__171`1 Void MoveNext() offset: 0x5A3
   -System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
   -System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x26
   -System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
   -System.Runtime.CompilerServices.TaskAwaiter Void GetResult() offset: 0x0
   -System.Net.Security.SslStream System.Threading.Tasks.Task ProcessAuthentication(Boolean, Boolean, System.Threading.CancellationToken) offset: 0x63
   -System.Net.Security.SslStream Void AuthenticateAsClient(System.Net.Security.SslClientAuthenticationOptions) offset: 0x39
   -System.Net.Http.ConnectHelper+<EstablishSslConnectionAsyncCore>d__4 Void MoveNext() offset: 0xD0

Source=System.Private.CoreLib

-System.Runtime.ExceptionServices.ExceptionDispatchInfo Void Throw() offset: 0x11
-System.Runtime.CompilerServices.TaskAwaiter Void ThrowForNonSuccess(System.Threading.Tasks.Task) offset: 0x27
-System.Runtime.CompilerServices.TaskAwaiter Void HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) offset: 0x28
-System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter TResult GetResult() offset: 0xB
-LINQPad.DataContextManager+d__31 Void MoveNext() offset: 0x58D

First Chance Data:
-System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() offset=0x11

ODATA 8

Hello,
Any plan to upgrade your driver with Microsoft.OData 8 ?

CustomizedRequestMessage ignores system web proxy

The issue (found in v1.0.3.7) is that when you run Fiddler to debug your OData 4 queries, the system web proxy is ignored. Even if you check the "Use LINQPad web proxy" checkbox in the advanced properties, it's still ignored. You need to manually fill the info about the proxy (for fiddler, it's usually http://localhost:8888).

This is related to LINQPad.Util.GetWebProxy() that seems to be ignoring WebRequest.GetSystemWebProxy() (It may be a good idea to ask @albahari about the LINQPad utility method).

There is a workaround, re-register the proxy in the SendingRequest2 event:

this.SendingRequest2 += (s, e) =>
{
    ((HttpWebRequestMessage)e.RequestMessage).HttpWebRequest.Proxy = WebRequest.GetSystemWebProxy();
};

It would be nice if the driver would do it for us in the CustomizedRequestMessage implementation.

Option to accept invalid certificates

An option to accept invalid certificates would be very useful for test environments.
Thinking about something like this:

ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };

custom headers

Hello,
Great job,
But could you implement the custom headers feature like you did in the 1.3.0.8 ?

It's very usefull to authentify with a single token

Thanks

Issue when using lprun: NullReferenceException: Object reference not set to an instance of an object

Hi,
The OData 4 driver doesn't seem to play well with lprun.exe. When querying an OData 4 source and using lprun.exe to run the script, there's always an error. I'm using LINQPad v5.10.00 with the driver v1.0.3.4.

I used the following simple script:
var x = this.MyEntities.ToArray();

and it produced the following error:

D:\apps\LINQPad5>lprun.exe "C:\Users\maboivin\Documents\LINQPad Queries\test.linq" NullReferenceException: Object reference not set to an instance of an object. at OData4.OData4DynamicDriver.<>c__DisplayClass19_0.<InitializeContext>b__1(Object s, SendingRequest2EventArgs e) at Microsoft.OData.Client.DataServiceContext.FireSendingRequest2(SendingRequest2EventArgs eventArgs) at Microsoft.OData.Client.ODataRequestMessageWrapper.FireSendingRequest2(Descriptor descriptor) at Microsoft.OData.Client.DataServiceRequest.CreateExecuteResult(Object source, DataServiceContext context, AsyncCallback callback, Object state, String method) at Microsoft.OData.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents) at Microsoft.OData.Client.DataServiceQuery`1.Execute() at Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at UserQuery in C:\Users\maboivin\Documents\LINQPad Queries\test.linq:line 1 at LINQPad.ExecutionModel.ClrQueryRunner.Run() at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)

OData basic authorization

From LINQPad not able to authorize to OData. Using OData basic authorization.

Assemblies affected

LINQPad driver:
Name: OData 4
Version: 1.0.1.0
Author: Dimtrii Smirnov

OData endpoint: Microsoft.AspNet.OData v6.1.0(Latest at 23/11/2017)

LINQPad 5(Free Edition) v5.26.01

Reproduce steps

Custom AuthorizeAttribute is created:

public class ODataBasicAuthorizeAttribute : System.Web.Http.AuthorizeAttribute
 {
         public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            if (actionContext.Request.Headers.Authorization == null || actionContext.Request.Headers.Authorization.Scheme != "Basic")
            {
               
	    }
...
}

From LINQPad I have connection to OData endpoint and I'm able to see the table names:
odataconnection

Credentials are entered and pressing OK button:
linqpadlogin

Expected result

In OData endpoint custom class: ODataBasicAuthorizeAttribute , method: OnAuthorization ,actionContext.Request.Headers.Authorization should contain credentials that we entered from Login window(LINQPad) in screenshot.

Actual result

In OData endpoint custom class: ODataBasicAuthorizeAttribute , method: OnAuthorization ,actionContext.Request.Headers.Authorization value is null

Additional detail

In UI code there is functionality to select the type of authorization(Basic), but this choice is not shown in Login window in LINQPad:

<RadioButton Margin="0 0 0 4" IsChecked="{Binding Path=AuthenticationType, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static ui:AuthenticationType.Basic}}" TabIndex="3" x:Name="BasicAuthentication">_Basic authentication</RadioButton>

Suggested fix:
It would be good if we can select Basic authorization type and login to access data

Error when adding WebApi OData service

When I expand a newly added connection I get a Populating message that simply goes away after a few seconds. When I hover over the connection I get an error.

Error: EdmParseException - Encountered the following errors when parsing the EDMX document:
XmlError: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. : (0, 0)

Linqpad 5.10.00
driver version 1.0.3.7 (869742f)

Support open types and dynamic properties

Dynamic properties support has been added to the OData client 7.7.0, See this blog post for more details.

To support this new feature:

  • The Microsoft.OData.Client dependency needs to be updated to the latest version (7.9.0).
  • The ODataT4CodeGenerator needs to be updated to the one in the OData connected service which will give access to set a new property called EmitContainerPropertyAttribute to true.

On a side note, I was able to make it work by looking at the current code and removing the dependency on the FilesManager from the new ODataT4CodeGenerator from the OData connected service.
image

Do you think it's something that could be added for the next version of the driver?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.