Skip to content

Commit

Permalink
Fix multiple sp with same name
Browse files Browse the repository at this point in the history
  • Loading branch information
conwid committed Jan 14, 2019
1 parent b734061 commit 928a868
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 56 deletions.
2 changes: 1 addition & 1 deletion AzureDocumentDbDriver/AzureCosmosDbDriver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Debug DevDeploy.bat
if $(ConfigurationName) == Release powershell.exe -file "ReleaseDeploy.ps1" -folder "$(TargetDir)</PostBuildEvent>
if $(ConfigurationName) == Release powershell.exe -NonInteractive -executionPolicy Unrestricted -file "ReleaseDeploy.ps1" -folder "$(TargetDir)</PostBuildEvent>
</PropertyGroup>
<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')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
7 changes: 3 additions & 4 deletions AzureDocumentDbDriver/Common/DriverHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public static IEnumerable<string> GetNamespaceToAdd() =>

public static string GetConnectionDescription(IConnectionInfo cxInfo)
{
var props = new Properties(cxInfo);
List<ExpandoObject> o = new List<ExpandoObject>();
var props = new Properties(cxInfo);
return $"{props.Uri}/{props.Database}";
}

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

internal static IDbConnection GetIDbConnection(IConnectionInfo cxInfo)
{
Properties props = new Properties(cxInfo);
var props = new Properties(cxInfo);
return new CosmosDbSqlConnection(props.Uri, props.AccountKey, props.Database);
}

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

Expand Down
26 changes: 13 additions & 13 deletions AzureDocumentDbDriver/Common/Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ namespace AzureCosmosDbDriver.Common

public class Properties
{
readonly IConnectionInfo _cxInfo;
readonly XElement _driverData;
private readonly IConnectionInfo cxInfo;
private readonly XElement driverData;

public Properties(IConnectionInfo cxInfo)
{
_cxInfo = cxInfo;
_driverData = cxInfo.DriverData;
this.cxInfo = cxInfo;
driverData = cxInfo.DriverData;
}

public ICustomTypeInfo CustomTypeInfo => _cxInfo.CustomTypeInfo;
public ICustomTypeInfo CustomTypeInfo => cxInfo.CustomTypeInfo;

public bool Persist
{
get => _cxInfo.Persist;
set => _cxInfo.Persist = value;
get => cxInfo.Persist;
set => cxInfo.Persist = value;
}

public string Uri
{
get => (string)_driverData.Element("Uri") ?? string.Empty;
set => _driverData.SetElementValue("Uri", value);
get => (string)driverData.Element(nameof(Uri)) ?? string.Empty;
set => driverData.SetElementValue(nameof(Uri), value);
}

public string AccountKey
{
get => (string)_driverData.Element("AccountKey") ?? string.Empty;
set => _driverData.SetElementValue("AccountKey", value);
get => (string)driverData.Element(nameof(AccountKey)) ?? string.Empty;
set => driverData.SetElementValue(nameof(AccountKey), value);
}

public string Database
{
get => (string)_driverData.Element("Database") ?? string.Empty;
set => _driverData.SetElementValue("Database", value);
get => (string)driverData.Element(nameof(Database)) ?? string.Empty;
set => driverData.SetElementValue(nameof(Database), value);
}
}

Expand Down
9 changes: 5 additions & 4 deletions AzureDocumentDbDriver/Common/SchemaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static List<ExplorerItem> GetSchema(Properties props)
Children = new List<ExplorerItem>()
};

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

foreach (var sp in collection.Children.Single(s => s.Text == "Stored procedures").Children)
{
code = code + $" public IEnumerable<dynamic> {sp.Tag}(params dynamic[] parameters)" +
code = code + $" public IEnumerable<dynamic> {collection.Tag}_{sp.Tag}(params dynamic[] parameters)" +
"{" +
$" return base.ExecuteDynamicStoredProcedure(\"{sp.Tag}\",\"{collection.Tag}\", parameters).ToList();" +
"}";
Expand Down Expand Up @@ -112,8 +112,9 @@ private static void BuildAssembly(string code, AssemblyName name, string driverF
results = codeProvider.CompileAssemblyFromSource(options, code);
}
if (results.Errors.Count > 0)
throw new Exception
("Cannot compile typed context: " + results.Errors[0].ErrorText + " (line " + results.Errors[0].Line + ")");
{
throw new Exception("Cannot compile typed context: " + results.Errors[0].ErrorText + " (line " + results.Errors[0].Line + ")");
}
}
}
}
35 changes: 17 additions & 18 deletions AzureDocumentDbDriver/Dynamic/ConnectionDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@

namespace AzureCosmosDbDriver.Dynamic
{
/// <summary>
/// Interaction logic for ConnectionDialog.xaml
/// </summary>
public partial class ConnectionDialog : Window
{
private Properties properties;
/// <summary>
/// Interaction logic for ConnectionDialog.xaml
/// </summary>
public partial class ConnectionDialog : Window
{
private readonly Properties properties;

public ConnectionDialog(IConnectionInfo cxInfo)
{
cxInfo.DatabaseInfo.Provider = CosmosDbSqlProviderFactory.ProviderName;
DataContext = properties = new Properties (cxInfo);
Background = SystemColors.ControlBrush;
InitializeComponent ();
}
public ConnectionDialog(IConnectionInfo cxInfo)
{
cxInfo.DatabaseInfo.Provider = CosmosDbSqlProviderFactory.ProviderName;
properties = new Properties(cxInfo);
DataContext = properties;
Background = SystemColors.ControlBrush;
InitializeComponent();
}

void btnOK_Click (object sender, RoutedEventArgs e)
{
DialogResult = true;
}
}
private void btnOK_Click(object sender, RoutedEventArgs e) => DialogResult = true;

}
}
4 changes: 2 additions & 2 deletions AzureDocumentDbDriver/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
3 changes: 2 additions & 1 deletion AzureDocumentDbDriver/ReleaseDeploy.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param ([string] $folder)
param ([string] $folder)

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


If (Test-Path $targetFolder){
Remove-Item $targetFolder -Recurse -Force
}
Expand Down
24 changes: 13 additions & 11 deletions AzureDocumentDbDriver/Static/ConnectionDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public ConnectionDialog(IConnectionInfo cxInfo)
InitializeComponent();
}

void btnOK_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
}
private void btnOK_Click(object sender, RoutedEventArgs e) =>DialogResult = true;

void BrowseAssembly(object sender, RoutedEventArgs e)
{
Expand All @@ -48,21 +45,23 @@ void BrowseAssembly(object sender, RoutedEventArgs e)
};

if (dialog.ShowDialog() == true)
{
cxInfo.CustomTypeInfo.CustomAssemblyPath = dialog.FileName;
}
}

void ChooseType(object sender, RoutedEventArgs e)
private void ChooseType(object sender, RoutedEventArgs e)
{
string assemPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;
if (assemPath.Length == 0)
string assemblyPath = cxInfo.CustomTypeInfo.CustomAssemblyPath;
if (assemblyPath.Length == 0)
{
MessageBox.Show("First enter a path to an assembly.");
return;
}

if (!File.Exists(assemPath))
if (!File.Exists(assemblyPath))
{
MessageBox.Show("File '" + assemPath + "' does not exist.");
MessageBox.Show("File '" + assemblyPath + "' does not exist.");
return;
}

Expand All @@ -82,8 +81,11 @@ void ChooseType(object sender, RoutedEventArgs e)
return;
}

string result = (string)LINQPad.Extensibility.DataContext.UI.Dialogs.PickFromList("Choose Custom Type", customTypes);
if (result != null) cxInfo.CustomTypeInfo.CustomTypeName = result;
var result = (string)LINQPad.Extensibility.DataContext.UI.Dialogs.PickFromList("Choose Custom Type", customTypes);
if (result != null)
{
cxInfo.CustomTypeInfo.CustomTypeName = result;
}
}
}
}
2 changes: 1 addition & 1 deletion CosmosDbAdoNetProvider

0 comments on commit 928a868

Please sign in to comment.