I need some help translating this procedure (see below) to Entity Framework 4.0. Does anyone have any suggestions of how to port this over. The target project includes; Silverlight 4, WCF RIA Services, EF 4.0, SQL Server 2008 R2.
我的唯一要求是,它需要列入管理法,而不是储存程序。
Try
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
string sql = "OPEN SYMMETRIC KEY " + this._encryptKey;
sql += " DECRYPTION BY CERTIFICATE " + this._encrpytCert;
sql += " SELECT TOP (1) CONVERT(nvarchar(50),DECRYPTBYKEY(Field1)) AS Name";
sql += " FROM Table3";
sql += " ORDER BY CONVERT(nvarchar(50),DECRYPTBYKEY(Field1))";
cmd.CommandText = sql;
Name = (String)cmd.ExecuteScalar();
bRtn = false;
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print(ex.ToString());
}
Please let me know how I should set this up and thanks!