Note that there are some explanatory texts on larger screens.

plurals
  1. POstring.Contains with Linq To Sql return an Null exception
    text
    copied!<p>My Linq To Sql query </p> <pre><code>PROJETS = PROJETS.Where(p =&gt; (p.VilleArrive != "" &amp;&amp; p.VilleArrive != null) &amp;&amp; p.VilleArrive.Contains(alerte.VilleArrive)); </code></pre> <p>is translated like this </p> <pre><code>SELECT * // (many columns) FROM [dbo].[cov_Projet] AS [t0] WHERE ([t0].[VilleArrive] &lt;&gt; @p0) // city != "" AND ([t0].[VilleArrive] IS NOT NULL) // city != null AND ([t0].[VilleArrive] LIKE @p1) // city.contains(alert.city) ORDER BY [t0].[DateDebut] </code></pre> <p>It is well executed when i run it manually into sql server. But it returns a ArgumentNullException exception when executed by linq. Actually the column tested "VilleArrive" ("city") is never null but always an empty string</p> <p>I really don't understand why it appends. My problem looks like this one <a href="https://stackoverflow.com/questions/977159/linq-to-sql-and-null-strings-how-do-i-use-contains">LINQ to SQL and Null strings, how do I use Contains?</a> but answers do not work with me.</p> <p>The "LIKE" keyword seems to invoke the Linq.SqlClient.SqlHelpers.GetStringContainsPattern(String text, Char escape)</p> <p>Thank you for your help , sorry for my english.</p> <p>Here the stack trace my project is an ASP MVC 1.0 project</p> <blockquote> <p>System.ArgumentNullException was unhandled by user code Message="La valeur ne peut pas être null.\r\nNom du paramètre : text"<br> Source="System.Data.Linq"<br> ParamName="text" StackTrace: à System.Data.Linq.SqlClient.SqlHelpers.GetStringContainsPattern(String text, Char escape) à System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.TranslateStringMethod(SqlMethodCall mc) à System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitMethodCall(SqlMethodCall mc) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) à System.Data.Linq.SqlClient.SqlVisitor.VisitBinaryOperator(SqlBinary bo) à System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitBinaryOperator(SqlBinary bo) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitExpression(SqlExpression exp) à System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) à System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitSelect(SqlSelect select) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) à System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) à System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitSelect(SqlSelect select) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitUnion(SqlUnion su) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitAlias(SqlAlias a) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlVisitor.VisitSource(SqlSource source) à System.Data.Linq.SqlClient.SqlVisitor.VisitSelectCore(SqlSelect select) à System.Data.Linq.SqlClient.PostBindDotNetConverter.Visitor.VisitSelect(SqlSelect select) à System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node) à System.Data.Linq.SqlClient.SqlProvider.BuildQuery(ResultShape resultShape, Type resultType, SqlNode node, ReadOnlyCollection<code>1 parentParameters, SqlNodeAnnotations annotations) à System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations) à System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.GetQueryText(Expression query) à System.Data.Linq.DataQuery</code>1.ToString() à covCake.Services.ProjetAlerts.RetrieveProjectsByUsers(Boolean UpdateAlerts) dans D:\AspProject\covCake\covCake\Services\ProjetAlerts.cs:ligne 111 à covCake.Controllers.AlertesController.SendAlertEmail(String p) dans D:\AspProject\covCake\covCake\Controllers\AlertesController.cs:ligne 152 à lambda_method(ExecutionScope , ControllerBase , Object[] ) à System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) à System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary<code>2 parameters) à System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary</code>2 parameters) à System.Web.Mvc.ControllerActionInvoker.&lt;>c__DisplayClassa.b__7() à System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)<br> InnerException:</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload