Skip to content

Commit 928a868

Browse files
committed
Fix multiple sp with same name
1 parent b734061 commit 928a868

File tree

10 files changed

+58
-56
lines changed

10 files changed

+58
-56
lines changed

AzureDocumentDbDriver/AzureCosmosDbDriver.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
120120
<PropertyGroup>
121121
<PostBuildEvent>if $(ConfigurationName) == Debug DevDeploy.bat
122-
if $(ConfigurationName) == Release powershell.exe -file "ReleaseDeploy.ps1" -folder "$(TargetDir)</PostBuildEvent>
122+
if $(ConfigurationName) == Release powershell.exe -NonInteractive -executionPolicy Unrestricted -file "ReleaseDeploy.ps1" -folder "$(TargetDir)</PostBuildEvent>
123123
</PropertyGroup>
124124
<Import Project="..\packages\Microsoft.Azure.DocumentDB.1.22.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\packages\Microsoft.Azure.DocumentDB.1.22.0\build\Microsoft.Azure.DocumentDB.targets')" />
125125
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

AzureDocumentDbDriver/Common/DriverHelper.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public static IEnumerable<string> GetNamespaceToAdd() =>
3838

3939
public static string GetConnectionDescription(IConnectionInfo cxInfo)
4040
{
41-
var props = new Properties(cxInfo);
42-
List<ExpandoObject> o = new List<ExpandoObject>();
41+
var props = new Properties(cxInfo);
4342
return $"{props.Uri}/{props.Database}";
4443
}
4544

@@ -55,7 +54,7 @@ public static ParameterDescriptor[] GetContextConstructorParameters(IConnectionI
5554

5655
internal static IDbConnection GetIDbConnection(IConnectionInfo cxInfo)
5756
{
58-
Properties props = new Properties(cxInfo);
57+
var props = new Properties(cxInfo);
5958
return new CosmosDbSqlConnection(props.Uri, props.AccountKey, props.Database);
6059
}
6160

@@ -65,7 +64,7 @@ public static DbProviderFactory GetProviderFactory(IConnectionInfo cxInfo)
6564
{
6665
throw new NotSupportedException($"Only {CosmosDbSqlProviderFactory.ProviderName} is supported; requested {cxInfo.DatabaseInfo.Provider}");
6766
}
68-
Properties props = new Properties(cxInfo);
67+
var props = new Properties(cxInfo);
6968
return new CosmosDbSqlProviderFactory(props.Uri, props.AccountKey, props.Database);
7069
}
7170

AzureDocumentDbDriver/Common/Properties.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@ namespace AzureCosmosDbDriver.Common
77

88
public class Properties
99
{
10-
readonly IConnectionInfo _cxInfo;
11-
readonly XElement _driverData;
10+
private readonly IConnectionInfo cxInfo;
11+
private readonly XElement driverData;
1212

1313
public Properties(IConnectionInfo cxInfo)
1414
{
15-
_cxInfo = cxInfo;
16-
_driverData = cxInfo.DriverData;
15+
this.cxInfo = cxInfo;
16+
driverData = cxInfo.DriverData;
1717
}
1818

19-
public ICustomTypeInfo CustomTypeInfo => _cxInfo.CustomTypeInfo;
19+
public ICustomTypeInfo CustomTypeInfo => cxInfo.CustomTypeInfo;
2020

2121
public bool Persist
2222
{
23-
get => _cxInfo.Persist;
24-
set => _cxInfo.Persist = value;
23+
get => cxInfo.Persist;
24+
set => cxInfo.Persist = value;
2525
}
2626

2727
public string Uri
2828
{
29-
get => (string)_driverData.Element("Uri") ?? string.Empty;
30-
set => _driverData.SetElementValue("Uri", value);
29+
get => (string)driverData.Element(nameof(Uri)) ?? string.Empty;
30+
set => driverData.SetElementValue(nameof(Uri), value);
3131
}
3232

3333
public string AccountKey
3434
{
35-
get => (string)_driverData.Element("AccountKey") ?? string.Empty;
36-
set => _driverData.SetElementValue("AccountKey", value);
35+
get => (string)driverData.Element(nameof(AccountKey)) ?? string.Empty;
36+
set => driverData.SetElementValue(nameof(AccountKey), value);
3737
}
3838

3939
public string Database
4040
{
41-
get => (string)_driverData.Element("Database") ?? string.Empty;
42-
set => _driverData.SetElementValue("Database", value);
41+
get => (string)driverData.Element(nameof(Database)) ?? string.Empty;
42+
set => driverData.SetElementValue(nameof(Database), value);
4343
}
4444
}
4545

AzureDocumentDbDriver/Common/SchemaBuilder.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static List<ExplorerItem> GetSchema(Properties props)
2525
Children = new List<ExplorerItem>()
2626
};
2727

28-
List<DocumentCollection> collections = client.CreateDocumentCollectionQuery(database.SelfLink).ToList();
28+
var collections = client.CreateDocumentCollectionQuery(database.SelfLink).ToList();
2929
foreach (var collection in collections)
3030
{
3131
var collectionItem = new ExplorerItem(collection.Id, ExplorerItemKind.QueryableObject, ExplorerIcon.Table) { IsEnumerable = true, Tag = collection.Id, Children = new List<ExplorerItem>() };
@@ -78,7 +78,7 @@ private static string GenerateCode(IEnumerable<ExplorerItem> collections, string
7878

7979
foreach (var sp in collection.Children.Single(s => s.Text == "Stored procedures").Children)
8080
{
81-
code = code + $" public IEnumerable<dynamic> {sp.Tag}(params dynamic[] parameters)" +
81+
code = code + $" public IEnumerable<dynamic> {collection.Tag}_{sp.Tag}(params dynamic[] parameters)" +
8282
"{" +
8383
$" return base.ExecuteDynamicStoredProcedure(\"{sp.Tag}\",\"{collection.Tag}\", parameters).ToList();" +
8484
"}";
@@ -112,8 +112,9 @@ private static void BuildAssembly(string code, AssemblyName name, string driverF
112112
results = codeProvider.CompileAssemblyFromSource(options, code);
113113
}
114114
if (results.Errors.Count > 0)
115-
throw new Exception
116-
("Cannot compile typed context: " + results.Errors[0].ErrorText + " (line " + results.Errors[0].Line + ")");
115+
{
116+
throw new Exception("Cannot compile typed context: " + results.Errors[0].ErrorText + " (line " + results.Errors[0].Line + ")");
117+
}
117118
}
118119
}
119120
}

AzureDocumentDbDriver/Dynamic/ConnectionDialog.xaml.cs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,23 @@
1717

1818
namespace AzureCosmosDbDriver.Dynamic
1919
{
20-
/// <summary>
21-
/// Interaction logic for ConnectionDialog.xaml
22-
/// </summary>
23-
public partial class ConnectionDialog : Window
24-
{
25-
private Properties properties;
20+
/// <summary>
21+
/// Interaction logic for ConnectionDialog.xaml
22+
/// </summary>
23+
public partial class ConnectionDialog : Window
24+
{
25+
private readonly Properties properties;
2626

27-
public ConnectionDialog(IConnectionInfo cxInfo)
28-
{
29-
cxInfo.DatabaseInfo.Provider = CosmosDbSqlProviderFactory.ProviderName;
30-
DataContext = properties = new Properties (cxInfo);
31-
Background = SystemColors.ControlBrush;
32-
InitializeComponent ();
33-
}
27+
public ConnectionDialog(IConnectionInfo cxInfo)
28+
{
29+
cxInfo.DatabaseInfo.Provider = CosmosDbSqlProviderFactory.ProviderName;
30+
properties = new Properties(cxInfo);
31+
DataContext = properties;
32+
Background = SystemColors.ControlBrush;
33+
InitializeComponent();
34+
}
3435

35-
void btnOK_Click (object sender, RoutedEventArgs e)
36-
{
37-
DialogResult = true;
38-
}
39-
}
36+
private void btnOK_Click(object sender, RoutedEventArgs e) => DialogResult = true;
37+
38+
}
4039
}

AzureDocumentDbDriver/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0.0")]
36-
[assembly: AssemblyFileVersion("2.0.0.0")]
35+
[assembly: AssemblyVersion("2.1.0.0")]
36+
[assembly: AssemblyFileVersion("2.1.0.0")]

AzureDocumentDbDriver/ReleaseDeploy.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
param ([string] $folder)
1+
param ([string] $folder)
22

33
$sourceFolder=[System.IO.Path]::Combine($folder.Replace('"',''))
44
$targetFolder=[System.IO.Path]::Combine($sourceFolder,"ReleasePackage")
@@ -7,6 +7,7 @@ $pngFiles=[System.IO.Path]::Combine($sourceFolder,"*.png");
77
$dllFiles=[System.IO.Path]::Combine($sourceFolder,"*.dll")
88
$zipFile=[System.IO.Path]::Combine($sourceFolder,"AzureCosmosDbDriver.lpx")
99

10+
1011
If (Test-Path $targetFolder){
1112
Remove-Item $targetFolder -Recurse -Force
1213
}

AzureDocumentDbDriver/Static/ConnectionDialog.xaml.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public ConnectionDialog(IConnectionInfo cxInfo)
3434
InitializeComponent();
3535
}
3636

37-
void btnOK_Click(object sender, RoutedEventArgs e)
38-
{
39-
DialogResult = true;
40-
}
37+
private void btnOK_Click(object sender, RoutedEventArgs e) =>DialogResult = true;
4138

4239
void BrowseAssembly(object sender, RoutedEventArgs e)
4340
{
@@ -48,21 +45,23 @@ void BrowseAssembly(object sender, RoutedEventArgs e)
4845
};
4946

5047
if (dialog.ShowDialog() == true)
48+
{
5149
cxInfo.CustomTypeInfo.CustomAssemblyPath = dialog.FileName;
50+
}
5251
}
5352

54-
void ChooseType(object sender, RoutedEventArgs e)
53+
private void ChooseType(object sender, RoutedEventArgs e)
5554
{
56-
string assemPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;
57-
if (assemPath.Length == 0)
55+
string assemblyPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;
56+
if (assemblyPath.Length == 0)
5857
{
5958
MessageBox.Show("First enter a path to an assembly.");
6059
return;
6160
}
6261

63-
if (!File.Exists(assemPath))
62+
if (!File.Exists(assemblyPath))
6463
{
65-
MessageBox.Show("File '" + assemPath + "' does not exist.");
64+
MessageBox.Show("File '" + assemblyPath + "' does not exist.");
6665
return;
6766
}
6867

@@ -82,8 +81,11 @@ void ChooseType(object sender, RoutedEventArgs e)
8281
return;
8382
}
8483

85-
string result = (string)LINQPad.Extensibility.DataContext.UI.Dialogs.PickFromList("Choose Custom Type", customTypes);
86-
if (result != null) cxInfo.CustomTypeInfo.CustomTypeName = result;
84+
var result = (string)LINQPad.Extensibility.DataContext.UI.Dialogs.PickFromList("Choose Custom Type", customTypes);
85+
if (result != null)
86+
{
87+
cxInfo.CustomTypeInfo.CustomTypeName = result;
88+
}
8789
}
8890
}
8991
}

CosmosDbAdoNetProvider

0 commit comments

Comments
 (0)