let stringArray = ["88612345678", "98765432", "55587654321"]
let result = stringArray.map{String($0.characters.suffix(8))}
print(result) // "["12345678", "98765432", "87654321"]\n"
string _serverSelected;
public string serverSelected
{
get { return _serverSelected; }
set
{
if (_serverSelected != value)
_serverSelected = value;
RaisePropertyChanged("serverSelected");
}
}
public BackUpViewModel()
{
BackUpContext servObj = new BackUpContext();
_DBNameList = servObj.GetDBNames(serverSelected);
}
public List<string> GetDBNames(string sqlServerName)
{
List<string> lstDBName = new List<string>();
SqlConnectionStringBuilder connection = new SqlConnectionStringBuilder();
connection.DataSource = sqlServerName;
connection.IntegratedSecurity = true;
String strCon = connection.ToString();
SqlConnection sqlConn = new SqlConnection(strCon);
sqlConn.Open();
SqlCommand cmd = new SqlCommand("select * from sys.databases", sqlConn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
lstDBName.Add(dr[0].ToString());
}
sqlConn.Close();
return lstDBName;
}
<configuration>
<connectionStrings>
<add name="CostAllocationEntities2" connectionString="Data Source=pc210090\SQLExpress;Persist Security Info=True;User ID=sa;Password=password1$" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="ServerName1" value="PC210090\SQLEXPRESS"/>
<add key="ServerName2" value="s2"/>
<add key="ServerName3" value="s3"/>
<add key="BackupDestinationPath" value="D:\BackUpDatabase\"/>
<add key="RestoreDestinationPath" value="D:\RestoreDatabase\"/>
</appSettings>
</configuration>
这个serverSelected总是传递为null,这不允许我的代码构建,因此我无法从服务器列表中选择服务器。