SearchExtensions icon indicating copy to clipboard operation
SearchExtensions copied to clipboard

Search in every Column of query | .Search() in query | Linq to Entities

Open yunuza opened this issue 7 years ago • 2 comments

Hi, I have a problem or maybe just a question. I've just seen your post on stackoverflow and finally found your library (https://stackoverflow.com/questions/18292618/linq-search-multiple-columns)

My code shortened looks like that:

public int _DokumentID { get; set; }
public string _Dokumentnr { get; set; }
public string _Dokumenttyp { get; set; }

        var query = from Dok in dbContext.Dokumente
                join ReAdr in dbContext.Adressen on Dok.REAdresseID equals ReAdr.AdresseID into ad
                from subReAdresse in ad.DefaultIfEmpty()
                select new ClassDok()
                {
                        _DokumentID = Dok.DokumentID,
                        _Dokumentnr = Dok.Dokumentnr,
                        _Dokumenttyp = Dok.Dokumenttyp,
                        _rFirma = subReAdresse.Firma
}

Now I want to Search in that query for a String. I thought it would be just using this: query = query.Search().Containing("Searchparam"); But if I run that code, I get weird error messages that has nothing to do with the actual part of code that is in use.

Is it even possible to use .Search() in my scenario?

I also tested query = query.Search(x => x._Dokumentnr).Containing(parSuchbegriff); and that works.

yunuza avatar Dec 05 '17 09:12 yunuza

Hi @yunuza,

Are you able to provide the error message that you are experiencing? If you commit the query to memory (.ToList()) and then try the search do you get a different result?

Thanks John

ninjanye avatar Jan 05 '18 09:01 ninjanye

Hi, I'm having a similar problem using query = query.Search().Containing("Searchparam");, but in my case I don't get any errors, instead it seams to not been searching at all because it returns all the data. I'm using a previous version of Ninjaye in other project and it works as expected when trying to search in every column including relations. Any suggestion?

yrmartinez avatar Apr 16 '18 23:04 yrmartinez