C# – LINQ to Entities does not recognize the method ‘System.String ToString()’ method and this method cannot be translated into a store expression

asp.netc++linq

when I trying to run following code.

var result = from c in db.brand
             where c.title.contains("test")
             select c.title + "-" +c.brand;

List<string> lst = r.ToList();

it gives following error.

LINQ to Entities does not recognize the method 'System.String
ToString()' method, and this method cannot be translated into a store
expression.

Best Solution

I would suggest fetching the title and the brand in an anonymous type, and then performing the string concatenation in-process:

var list = db.Brand.Where(c => c.Title.Contains("test"))
                   .Select(c => new { c.Title, c.Brand })
                   .AsEnumerable() // Rest of the query in-process
                   .Select(x => x.Title + " " + x.Brand)
                   .ToList();