示例#1
0
        /// <summary>
        /// Returns information about the installed SQL Server LocalDB version(s).
        /// </summary>
        /// <returns>
        /// An <see cref="IList&lt;ISqlLocalDbVersionInfo&gt;"/> containing information
        /// about the SQL Server LocalDB version(s) installed on the current machine.
        /// </returns>
        public virtual IList <ISqlLocalDbVersionInfo> GetVersions()
        {
            IList <string> versionNames = _localDB.Versions;

            List <ISqlLocalDbVersionInfo> versions = new List <ISqlLocalDbVersionInfo>();

            if (versionNames != null)
            {
                foreach (string version in versionNames)
                {
                    ISqlLocalDbVersionInfo info = _localDB.GetVersionInfo(version);
                    versions.Add(info);
                }
            }

            return(versions);
        }
示例#2
0
        /// <summary>
        /// Returns information about the installed SQL Server LocalDB version(s).
        /// </summary>
        /// <param name="api">The <see cref="ISqlLocalDbApi"/> to use to enumerate the installed versions.</param>
        /// <returns>
        /// An <see cref="IReadOnlyList{ISqlLocalDbVersionInfo}"/> containing information
        /// about the SQL Server LocalDB version(s) installed on the current machine.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="api"/> is <see langword="null"/>.
        /// </exception>
        public static IReadOnlyList <ISqlLocalDbVersionInfo> GetVersions(this ISqlLocalDbApi api)
        {
            if (api == null)
            {
                throw new ArgumentNullException(nameof(api));
            }

            IReadOnlyList <string> versionNames = api.Versions;
            var versions = new List <ISqlLocalDbVersionInfo>(versionNames?.Count ?? 0);

            if (versionNames != null)
            {
                foreach (string version in versionNames)
                {
                    ISqlLocalDbVersionInfo info = api.GetVersionInfo(version);
                    versions.Add(info);
                }
            }

            return(versions);
        }