Exemplo n.º 1
0
        protected virtual void ConfigureServerName(
            dynamic /*SqlConnectionStringBuilder*/ builder)
        {
            var dataSource = ServerName.NullIfEmpty() ?? LocalServerName;

            if (ServerPort.HasValue || InstanceName.HasContent())
            {
                var s = new StringBuilder(dataSource);

                if (InstanceName.HasContent())
                {
                    s.Append('\\').Append(InstanceName);
                }

                if (ServerPort.HasValue)
                {
                    s.Append(',').Append(ServerPort.Value.ToString(CultureInfo.InvariantCulture));
                }

                dataSource = s.ToString();
            }

            builder.DataSource = dataSource;
        }