I have one column in a database table containing state data like 33:Rio de Janeiro. I want to extract the code 33 using a LINQ expresion. Here is my code.
public string command(string query)
{
string res = string.Empty;
MySqlConnection conn = new MySqlConnection(MysqlConnect());
MySqlCommand cmd = new MySqlCommand(query,conn);
res = cmd.ExecuteScalar().ToString();
conn.Close();
return res;
}
Here I want to get the code of the state.
string code = db.command("select cidade from logos ")
.Split(':')
.Where(<Expression to get the first part>);
Please help me.
1 Answer