How do I perform a query on the database using Entity Framework 4 by passing a previously stored string within a StringBuilder
.
The reason is that the SQL query string is giant. I know it is not a good practice, but for now I will have to do it for lack of time.
This is the SQL of the query:
StringBuilder strSql = new StringBuilder();
strSql.AppendLine(string.Format("SELECT * FROM (SELECT TOP intRestante * FROM (SELECT TOP {0}", intTop))[... Continua, a string é gigante];
In WebForms I would do something like this:
objCommand = new SqlCommand();
objCommand.Connection = conn;
objCommand.CommandTimeout = 600;
objCommand.CommandText = strSql.ToString();
objCommand.Parameters.Add("@Parametros", SqlDbType.NVarChar, 100).Value = "%" + strParametros + "%";
SqlDataAdapter adp = new SqlDataAdapter(objCommand);
adp.Fill(dt);
I would like to know how to do exactly the same thing, but in Entity Framework.