user940602
user940602

Reputation: 73

Linq Query, Where Contains

I have this simple query:

SELECT     xObjectID, xObjectName
FROM         dbo.xObject
where  CONTAINS( xObjectRef, '1838 AND 238671')

Which i am trying to convert to linq but i can't get it to work, And it's driving me up the wall.

Thanks!

Upvotes: 1

Views: 239

Answers (4)

Royi Namir
Royi Namir

Reputation: 148744

   var  a = xObject.where(n=>n.Contains("1838") && n.Contains("238671") )).
                    Select(s=>new {xObjectID=s.xObjectID , xObjectName=s.xObjectName});

Upvotes: 0

ionden
ionden

Reputation: 12786

var query = from c in context.xObject 
             where c.xObjectRef.Contains("1838") && c.xObjectRef.Contains("238671")
             select new { ObjectID = c.xObjectID, ObjectName = c.xObjectName };

Upvotes: 1

Ropstah
Ropstah

Reputation: 17804

Does this work for you? This does require xObjectRef to be a property of xObject.

from obj in dbo.xObject
where obj.xObjectRef.Contains("1838") && obj.xObjectRef.Contains("238671")
select new { xObjectId = obj.xObjectId, xObjectName = obj.xObjectName}

Upvotes: 1

Umair
Umair

Reputation: 3253

Fulltext searches are not compatible with linq to sql. You will have to call a stored procedure.

Edit:

Or do you want a linq query that will return the same result set as the sql?

Upvotes: 1

Related Questions