0

とにかくこのエラーの周りにありますか? 重複するのではなく、他のクエリで同じラムバ式を再利用したいと思います。LinqKit または他の linq 式でこれを行うことはできますか?

エラー

LINQ to Entities はメソッド 'Boolean GetEvent(Tournaments.Data.Entities.Event, System.String)' メソッドを認識せず、このメソッドをストア式に変換できません。

コード

public MobileEventDetailModel GetDetails(string applicationId)
{
    var @event = (from e in _eventsRepository.DataContext.Events.Include(q => q.Assets.Select(a => a.Asset))
                  where GetEvent(e, applicationId)
                select new
                    {
                        e.Id,
                        e.EventParent.Name,
                        LogoId = (from a in e.Assets
                                     where a.Type   == EventAssetType.Logo
                                     select a.AssetId).FirstOrDefault()
                    }).FirstOrDefault();

    return new MobileEventDetailModel
        {
            Id = @event.Id,
            Name = @event.Name,
            Logo = string.Format("{0}{1}{2}", Config.BaseUrl, Config.ImagesPath, @event.LogoId)
        };
}

public bool GetEvent(Event @event, string applicationId)
{

    return @event.Active && @event.Visible && @event.MobileEventApplications.Any(m =>
                          m.MobileApplication.ApplicationId == applicationId &&
                          (!m.MobileApplication.ActivationLength.HasValue || EntityFunctions.AddDays(DateTime.Now, 1) < EntityFunctions.AddMonths(m.MobileApplication.DateActivated, m.MobileApplication.ActivationLength.Value)));
}
4

1 に答える 1