diff --git a/AzureDocumentDbDriver/AzureCosmosDbDriver.csproj b/AzureDocumentDbDriver/AzureCosmosDbDriver.csproj index 7f57eda..6f1c6f6 100644 --- a/AzureDocumentDbDriver/AzureCosmosDbDriver.csproj +++ b/AzureDocumentDbDriver/AzureCosmosDbDriver.csproj @@ -119,7 +119,7 @@ if $(ConfigurationName) == Debug DevDeploy.bat -if $(ConfigurationName) == Release powershell.exe -file "ReleaseDeploy.ps1" -folder "$(TargetDir) +if $(ConfigurationName) == Release powershell.exe -NonInteractive -executionPolicy Unrestricted -file "ReleaseDeploy.ps1" -folder "$(TargetDir) diff --git a/AzureDocumentDbDriver/Common/DriverHelper.cs b/AzureDocumentDbDriver/Common/DriverHelper.cs index 6546e69..8e88a09 100644 --- a/AzureDocumentDbDriver/Common/DriverHelper.cs +++ b/AzureDocumentDbDriver/Common/DriverHelper.cs @@ -38,8 +38,7 @@ public static IEnumerable GetNamespaceToAdd() => public static string GetConnectionDescription(IConnectionInfo cxInfo) { - var props = new Properties(cxInfo); - List o = new List(); + var props = new Properties(cxInfo); return $"{props.Uri}/{props.Database}"; } @@ -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); } @@ -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); } diff --git a/AzureDocumentDbDriver/Common/Properties.cs b/AzureDocumentDbDriver/Common/Properties.cs index a6ffb5f..67d4d99 100644 --- a/AzureDocumentDbDriver/Common/Properties.cs +++ b/AzureDocumentDbDriver/Common/Properties.cs @@ -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); } } diff --git a/AzureDocumentDbDriver/Common/SchemaBuilder.cs b/AzureDocumentDbDriver/Common/SchemaBuilder.cs index a0ebfbd..de79ca1 100644 --- a/AzureDocumentDbDriver/Common/SchemaBuilder.cs +++ b/AzureDocumentDbDriver/Common/SchemaBuilder.cs @@ -25,7 +25,7 @@ public static List GetSchema(Properties props) Children = new List() }; - List 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() }; @@ -78,7 +78,7 @@ private static string GenerateCode(IEnumerable collections, string foreach (var sp in collection.Children.Single(s => s.Text == "Stored procedures").Children) { - code = code + $" public IEnumerable {sp.Tag}(params dynamic[] parameters)" + + code = code + $" public IEnumerable {collection.Tag}_{sp.Tag}(params dynamic[] parameters)" + "{" + $" return base.ExecuteDynamicStoredProcedure(\"{sp.Tag}\",\"{collection.Tag}\", parameters).ToList();" + "}"; @@ -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 + ")"); + } } } } diff --git a/AzureDocumentDbDriver/Dynamic/ConnectionDialog.xaml.cs b/AzureDocumentDbDriver/Dynamic/ConnectionDialog.xaml.cs index ff63565..ee2cc03 100644 --- a/AzureDocumentDbDriver/Dynamic/ConnectionDialog.xaml.cs +++ b/AzureDocumentDbDriver/Dynamic/ConnectionDialog.xaml.cs @@ -17,24 +17,23 @@ namespace AzureCosmosDbDriver.Dynamic { - /// - /// Interaction logic for ConnectionDialog.xaml - /// - public partial class ConnectionDialog : Window - { - private Properties properties; + /// + /// Interaction logic for ConnectionDialog.xaml + /// + 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; + + } } diff --git a/AzureDocumentDbDriver/Properties/AssemblyInfo.cs b/AzureDocumentDbDriver/Properties/AssemblyInfo.cs index cc884f2..c6b10b1 100644 --- a/AzureDocumentDbDriver/Properties/AssemblyInfo.cs +++ b/AzureDocumentDbDriver/Properties/AssemblyInfo.cs @@ -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")] diff --git a/AzureDocumentDbDriver/ReleaseDeploy.ps1 b/AzureDocumentDbDriver/ReleaseDeploy.ps1 index 8c85676..9b38436 100644 --- a/AzureDocumentDbDriver/ReleaseDeploy.ps1 +++ b/AzureDocumentDbDriver/ReleaseDeploy.ps1 @@ -1,4 +1,4 @@ - param ([string] $folder) +param ([string] $folder) $sourceFolder=[System.IO.Path]::Combine($folder.Replace('"','')) $targetFolder=[System.IO.Path]::Combine($sourceFolder,"ReleasePackage") @@ -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 } diff --git a/AzureDocumentDbDriver/Static/ConnectionDialog.xaml.cs b/AzureDocumentDbDriver/Static/ConnectionDialog.xaml.cs index 6c04fe9..f9a9c19 100644 --- a/AzureDocumentDbDriver/Static/ConnectionDialog.xaml.cs +++ b/AzureDocumentDbDriver/Static/ConnectionDialog.xaml.cs @@ -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) { @@ -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; } @@ -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; + } } } } diff --git a/CosmosDbAdoNetProvider b/CosmosDbAdoNetProvider index a400fe9..0afceb7 160000 --- a/CosmosDbAdoNetProvider +++ b/CosmosDbAdoNetProvider @@ -1 +1 @@ -Subproject commit a400fe917dcbabb4e3b6bf59322472b30383f91b +Subproject commit 0afceb7f62be383a527a5cd51d9ca118daf0abee diff --git a/CosmosDbContext b/CosmosDbContext index 7db76a8..5aa2c9e 160000 --- a/CosmosDbContext +++ b/CosmosDbContext @@ -1 +1 @@ -Subproject commit 7db76a870edc8374b428a5f92a2ffb53c8355e38 +Subproject commit 5aa2c9e64df6ea30b66d91646541910ad27049e2