src/Misc/EntityFramework.PowerShell/ConnectionFactoryConfig/SqlServerDetector.cs
// <summary>
// Returns the highest version of LocalDB installed, or null if none was found.
// </summary>
// <remarks>
// If one version is found, then that version is always returned.
// If multiple versions are found, then an attempt to treat those versions as decimal numbers is
// made and the highest of these is returned.
// </remarks>
Returns the highest version of LocalDB installed, or null if none was found.
Returns the highest version of LocalDB installed or null if none was found .
public virtual string GetLocalDBVersionInstalled()
        {
            var key = OpenLocalDBInstalledVersions(useWow6432Node: false);
            if (key.SubKeyCount == 0)
            {
                key = OpenLocalDBInstalledVersions(useWow6432Node: true);
            }
            var orderableVersions = new List<Tuple<decimal, string>>();
            foreach (var subKey in key.GetSubKeyNames())
            {
                decimal decimalVersion;
                if (Decimal.TryParse(subKey, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out decimalVersion))
                {
                    orderableVersions.Add(Tuple.Create(decimalVersion, subKey));
                }
            }
            var highestVersion = orderableVersions.OrderByDescending(v => v.Item1).FirstOrDefault();
            if (highestVersion == null
                || highestVersion.Item2 == null
                || highestVersion.Item1 >= 12.0m)
            {
                return "mssqllocaldb";
            }
            return "v" + highestVersion.Item2;
        }
public virtual string GetLocalDBVersionInstalled ( ) { var key = OpenLocalDBInstalledVersions ( useWow6432Node : false ) ; if ( key . SubKeyCount == 0 ) { key = OpenLocalDBInstalledVersions ( useWow6432Node : true ) ; } var orderableVersions = new List < Tuple < decimal , string > > ( ) ; foreach ( var subKey in key . GetSubKeyNames ( ) ) { decimal decimalVersion ; if ( Decimal . TryParse ( subKey , NumberStyles . AllowDecimalPoint , CultureInfo . InvariantCulture , out decimalVersion ) ) { orderableVersions . Add ( Tuple . Create ( decimalVersion , subKey ) ) ; } } var highestVersion = orderableVersions . OrderByDescending ( v => v . Item1 ) . FirstOrDefault ( ) ; if ( highestVersion == null || highestVersion . Item2 == null || highestVersion . Item1 >= 12.0m ) { return " " ; } return " " + highestVersion . Item2 ; }
Returns the highest version of LocalDB installed, or null if none was found.
Returns the highest version of LocalDB installed or null if none was found .
// For v12.0 and higher the instance name is mssqllocaldb. See CodePlex 2246.
remarks
If one version is found, then that version is always returned.
If multiple versions are found, then an attempt to treat those versions as decimal numbers is
made and the highest of these is returned.
If one version is found then that version is always returned . If multiple versions are found then an attempt to treat those versions as decimal numbers is made and the highest of these is returned .