C#C
C#4y ago
7 replies
Alerin

Passing the where parameters by the function

How do I get this sample code to work? Unfortunately, it does not want to work.
    public async Task<User> GetAsync(Func<Models.User, bool> selector)
    {
        _model = await this.GetData().Where(x => selector(x)).SingleOrDefaultAsync() ?? new();
        return new(_context, _model);
    }

Use:
var user = await User.GetAsync(x => x.Mail == Model.Identifier || (x.Phone == Model.Identifier && x.PhoneCode == Model.PhoneCode));
Was this page helpful?