Skip to content

Commit ca3bbd4

Browse files
authored
Merge pull request #7 from bdkoepke/master
Adding CredentialOData support.
2 parents d932761 + 7bb2cce commit ca3bbd4

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

Client/Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<ItemGroup>
5757
<Compile Include="Credential.cs" />
5858
<Compile Include="CredentialSQL.cs" />
59+
<Compile Include="CredentialOData.cs" />
5960
<Compile Include="CredentialWeb.cs" />
6061
<Compile Include="CredentialFile.cs" />
6162
<Compile Include="Credentials.cs" />

Client/Credential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace PowerQueryNet.Client
1717
[KnownType(typeof(CredentialWeb))]
1818
[XmlInclude(typeof(CredentialSQL))]
1919
[KnownType(typeof(CredentialSQL))]
20+
[XmlInclude(typeof(CredentialOData))]
21+
[KnownType(typeof(CredentialOData))]
2022
public abstract class Credential
2123
{
2224

Client/CredentialOData.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace PowerQueryNet.Client
8+
{
9+
/// <summary>
10+
/// Credential to access an OData resource from the Power Query (M) formulas.
11+
/// </summary>
12+
public class CredentialOData : Credential
13+
{
14+
/// <summary>
15+
/// URL address of the resource
16+
/// </summary>
17+
public string Url { get; set; }
18+
}
19+
}

Engine/CommandCredentials.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public void SetCredentialSQL(string path)
4848
return;
4949
}
5050

51+
public void SetCredentialOData(string url)
52+
{
53+
DataSource dataSource = new DataSource("OData", url);
54+
DataSourceSetting dataSourceSetting = new DataSourceSetting("Anonymous");
55+
56+
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
57+
58+
return;
59+
}
60+
5161
public bool LoadCredentials(string fileName)
5262
{
5363
try

Service/PowerQueryService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public ExecuteResponse Execute(ExecuteRequest executeRequest)
144144
commandCredentials.SetCredentialWeb(((CredentialWeb)credential).Url);
145145
else if (credential is CredentialSQL)
146146
commandCredentials.SetCredentialSQL(((CredentialSQL)credential).SQL);
147+
else if (credential is CredentialOData)
148+
commandCredentials.SetCredentialOData(((CredentialOData)credential).Url);
147149
else
148150
throw new NotImplementedException("This Credential kind is not supported for now.");
149151
}

0 commit comments

Comments
 (0)