Random situation Where is LINQtoSQL?

I want to check if a (Case-Sensitive) tag exists in a SQL Server 2005 table using LINQtoSQL. Say if the tag "BEYONCE" exists in the tags, then I want me to be able to add "beyonce" or "BeYOnce", but not "BEYONCE" again. Here is the LINQ query I wrote:

From t In Context.Tags
Where String.Equals(t.Tag, myTag, StringComparison.Ordinal) = True 

But he says that the "Boolean Equals (System.String, System.String, System.StringComparison)" method does not support SQL translation. How can I find a case sensitive tag?

+3
source share
2 answers

, "blah" "BLAH" . , LinqToSQL, , ... i.e.

  String tag = "beYONCE";   IEnumerable result = db.ExecuteQuery(typeof (Int32),        " * 1 COLLATE Latin1_General_CS_AS = {0}", );

, "beyonce" , "beYONCE". "beyonce" .

, .

, .

+3

, linqtosql.

ExecuteExpression . , .


, # vb, #. , Tag

IEnumerable<Tag> matches = Context.ExecuteQuery<Tag>(
    "Select * from Tag where Tag = {0} COLLATE Latin1_General_CS_AS", myTag
);

, , vb.net: -)

dim matches as IEnumerable(Of Tag) = Context.ExecuteQuery(Of Tag)( _
    "Select * from Tag where Tag = {0} COLLATE Latin1_General_CS_AS", myTag _
)

, Chalkey.

0

Source: https://habr.com/ru/post/1711435/


All Articles