람다를 처음 사용. 이 질문은 구체적으로 람다 식으로 날짜 서식을 조작하는 것입니다. 스케줄러 시스템에서 모든 알림을 얻기 위해 사용되는 아래 코드 :날짜 형식을 지정하는 데 람다 식을 사용하는 방법
MyReminders = ScheduledActionService.GetActions().Where(
a => a.BeginTime.Date == Today
);
결과 집합을 반환하기 전에 날짜 형식을 변경할 수 있습니다.
.where ( a => a.BeginTime.Date == Today).Select( //the date and format BeginTime.date.ToString("d", new cultureInfo("zh-CN")) )
다음과 같이 날짜 형식을 변경하십시오.이 형식은 람다 식에서 작동합니까?
BeginTime.Date.ToString("d",new cultureInfo("zh-CN"),
감사합니다 당신의 도움을 주셔서 감사합니다.
------------ 업데이트 :
나는이 두 가지 방법을 시도했다. ListBox에 결과가 표시되지 않습니다.
이 스케줄러 시스템은 Windows Phone 7 용입니다.이 미리 알림 개체는 다음 속성을 포함합니다. 1) BeginTime, 2) 만료 시간, 3) 제목, 4) 컨텐트, 5) isSchedule 및 ohers
검색 후, 나는 ListBox에 DataBind해야합니다. ReminderListBox.ItemsSource = MyReminders;
1) var czech = new CultureInfo("zh-CN");
var MyReminders = ScheduledActionService.GetActions<Reminder>()
.Where(a => a.BeginTime.Date == Today)
.Select(a =>
new
{
Begindate = a.BeginTime.Date.ToString("d", czech),
Title = a.Title,
Content = a.Content
});
2) var czech = new CultureInfo("zh-CN"); var MyReminders = ScheduledActionService.GetActions() .Where(a => a.BeginTime.Date == Today) .Select(a => a.BeginTime.Date.ToString("d", czech));
< ListBox Name="ReminderListBox" >
< ListBox.ItemTemplate>
< DataTemplate>
< Grid Background="Transparent" Margin="0,0,0,30">
< StackPanel Orientation="Vertical" >
< TextBlock FontSize="23" Text="{Binding Title}"/ >
< TextBlock FontSize="23" Text="{Binding Content}" />
< StackPanel Orientation="Horizontal">
< TextBlock Text="begin "/>
< TextBlock x:Name="txtDate" Text="{Binding BeginTime}" />
< /StackPanel>
< StackPanel Orientation="Horizontal">
< TextBlock Text="expiration "/>
< TextBlock Text="{Binding ExpirationTime}"/>
< /StackPanel>
< StackPanel Orientation="Horizontal">
< TextBlock Text="recurrence "/>
< TextBlock Text="{Binding RecurrenceType}" />
< /StackPanel>
< StackPanel Orientation="Horizontal">
< TextBlock Text="is scheduled? "/>
< TextBlock Text="{Binding IsScheduled}"/>
< /StackPanel>
< /StackPanel>
< /Grid>
< /DataTemplate>
< /ListBox.ItemTemplate>
< /ListBox>