0

Linq ConvertAll メソッドから CalculateEndDateTime メソッドに filterSettnig パラメータを渡すにはどうすればよいですか?

public static List<IAppointment> ConvertToIAppointment(
                                 List<Misa.Runtime.Entities.Agenda> appointments,
                                 AgFilterDisplay filterSettnig)
{
    List<Misa.Agenda.IAppointment> result = null;
    if (appointments != null)
        result = appointments.ConvertAll<IAppointment>(CalculateEndDateTime(/*here i want to pass filterSettnig parameter*/));
    return result;
}

private static IAppointment CalculateEndDateTime(Entities.Agenda agenda, 
                                                 AgFilterDisplay filterSettnig)
{
    IAppointment result = null;

    if (agenda.ClusterID > 0)
    {
        if (agenda.StartDateTime.Date != agenda.EndDateTime.Date)
        {
            agenda.EndDateTime = agenda.StartDateTime.Date.Add(new TimeSpan(23, 59, 59));
        }
    }

    result = (IAppointment)agenda;

    return result;
}
4

1 に答える 1

2

SelectLINQ の一部である代わりに使用してください。ConvertAllList<T>メソッドであり、LINQ メソッドではありません。

result = appointments.Select(a => CalculateEndDateTime(a, filterSetting))
                     .ToList();
于 2012-12-05T14:42:26.233 に答える