This project has moved. For the latest updates, please go here.

is SqlQuery supported in effort with EF6 ?

Sep 14, 2015 at 9:57 PM
Edited Sep 14, 2015 at 9:57 PM
I have this sql
            var ctx = new MyContextContext();

            SqlParameter param1 = new SqlParameter("@hoy", hoy);
            SqlParameter param2 = new SqlParameter("@desde", primerDiaMes);
            SqlParameter param3 = new SqlParameter("@hasta", ultimoDiaMes);
            object[] parameters = new object[] { param1, param2, param3 };

            var s = new StringBuilder();
            s.Append("select * from Macs m ");
            s.Append("where m.Activo = 1 ");
            s.Append("and DATEDIFF(day, m.HeartBeat, @hoy) > 1 ");
            s.Append("and not exists  ");
            s.Append("  ( ");
            s.Append("      select 1  ");
            s.Append("      from AlertasHeartbeat a ");
            s.Append("      where a.MacId = m.Id  ");
            s.Append("      and a.FechaCreacion between @desde and @hasta ");
            s.Append("  ) ");
var a = ctx.Macs.SqlQuery(s.ToString(), parameters).ToList();

Gives the error:

StackTrace = " at Effort.Provider.EffortParameterCollection.AddRange(Array values)\r\n at System.Data.Entity.Core.Objects.ObjectContext.CreateStoreCommand(String commandText, Object[] parameters)\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteStoreQue...

Real context does work.

Thanks
Sep 17, 2015 at 2:06 AM
Ok is a limitation. Thanks