本文整理汇总了C#中ListItemCollection.FirstOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.FirstOrDefault方法的具体用法?C# ListItemCollection.FirstOrDefault怎么用?C# ListItemCollection.FirstOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListItemCollection
的用法示例。
在下文中一共展示了ListItemCollection.FirstOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckItemModified
/// <summary>
/// Checks if item is modified after it is loaded on the client side
/// </summary>
/// <param name="collection">List item collection</param>
/// <param name="cachedItemModifiedDate">Date time when current user loaded the page to see/update configuration values.</param>
/// <returns>Success flag</returns>
public static bool CheckItemModified(ListItemCollection collection, string cachedItemModifiedDate)
{
bool response = false;
int errorModifiedDate = 0; // If there is new list item being created then 'cachedItemModifiedDate' will be 0
if (null != collection && !string.IsNullOrWhiteSpace(cachedItemModifiedDate))
{
if (String.Equals(Convert.ToString(errorModifiedDate, CultureInfo.InvariantCulture), cachedItemModifiedDate) && collection.Count.Equals(0)) // Verify if new item flag is true and no list item is present in the Matter Configuration list
{
response = true;
}
else if (0 < collection.Count)
{
ListItem settingsListItem = collection.FirstOrDefault();
DateTime cachedDate;
if (DateTime.TryParse(cachedItemModifiedDate, out cachedDate))
{
DateTime itemModifiedDate = Convert.ToDateTime(settingsListItem[Constants.MODIFIED_DATE_COLUMN], CultureInfo.InvariantCulture);
if (0 == DateTime.Compare(cachedDate, itemModifiedDate))
{
response = true;
}
}
}
}
return response;
}