looking for some solutions? You are welcome.

SOLVED: Selecting based on string in a list C# LINQ


So I have a class named event which contains a List ListofInvites, It has email addresses of different user(another class which has a emailid property), now I want to select all the events based on whether the listofinvites string contains that specific email

I have tried this but i'm getting an error

var userEmailID = this.User.Identity.GetUserName();

var events = this.dataBase.Events
       .OrderBy(e => e.DateAndTime)
       .Where(e => e.listOfInvites.Contains(userEmailID))

Yeah sorry I was in a hurry last night when i posted this

So I have this event class

public class Event
    public Event()
        this.IsPublic = true;
        this.DateAndTime = DateTime.Now;
    public int EventID { get; set; }

    public string Title { get; set; }

    public DateTime DateAndTime { get; set; }

    public string AuthorId { get; set; }
    public int Duration { get; set; }
    public string Description { get; set; }
    public string OtherDetails { get; set; }
    public string Location { get; set; }
    public bool IsPublic { get; set; }
    public IEnumerable<string> listOfInvites { get; set; }

    public string  InviteList { get; set; }

the error i'm getting is

System.NotSupportedException: 'The specified type member 'listOfInvites' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.'

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: