i have following class:
public class contact { public int contactid { get; set; } public string firstname { get; set; } public string lastname { get; set; } } and following data:
- 1 / john / doe
- 2 / mike / tyson
- 3 / john / mc enroe
- 4 / stef / doe
now need let user search contacts this:
john doe> contacts having firstnamejohn, lastnamedoejohn> contacts having first namejohndoe> contacts having last namedoe- ...
i tried add notmapped element class , perform search on (full) name linq query not work notmapped elements.
[notmapped] public string name { { return firstname + " " + lastname; } } var = "john doe"; requests.where(s => s.contact.name.contains(someone)); the specified type member 'name' not supported in linq entities. initializers, entity members, , entity navigation properties supported.
any idea?
thanks.
i think don't need create not mapped property achieve need. can try this:
var = "john doe"; var contacts=context.contacts.where(c => string.concat(c.firstname, " ", p.lastname).contains(someone)); the string.concact method supported ef.
Comments
Post a Comment