Class ItemList
- Namespace
- Dynamicweb.Content.Items
- Assembly
- Dynamicweb.dll
ItemList holds the item relations.
public class ItemList : DbObject
- Inheritance
-
ItemList
- Inherited Members
Examples
using System.Collections.Generic;
using Dynamicweb.Content.Items;
namespace Dynamicweb.Examples.Items;
public sealed class ItemListSample
{
public static void CreteNewList()
{
// Add items to a new list
var list = new ItemList("ExampleNewsItem");
list.Relations = ItemServiceSample.CreateItems();
list.Save();
}
public static void ManageSavedList(int listId)
{
IList<ItemEntry> items = ItemServiceSample.CreateItems();
// Add items to a saved list
ItemList.AddRelation(listId, items[0].Id, 0);
ItemList.AddRelation(listId, items[1].Id, 1);
ItemList.AddRelation(listId, items[2].Id, 2);
// Delete list relations
ItemList.DeleteRelations(listId);
}
public static void DeleteList(int listId)
{
ItemList? list = ItemList.GetItemListById(listId);
// Delete a list, its relations and related items(if parameter = true)
if (list is not null)
list.DeleteWithRelations(true);
}
}
Constructors
ItemList()
public ItemList()
ItemList(string)
public ItemList(string itemType)
Parameters
itemTypestring
Properties
IsChangedOnLanguage
Gets or sets the flag that list on a language differs from master
public bool IsChangedOnLanguage { get; set; }
Property Value
ItemType
Gets or sets the type of the related items.
public string ItemType { get; set; }
Property Value
Relations
Gets or sets the related items.
public IEnumerable<ItemEntry> Relations { get; set; }
Property Value
SortBy
Gets or sets the field to sort the items
public string? SortBy { get; set; }
Property Value
SortOrder
Gets or sets the sort order
public string? SortOrder { get; set; }
Property Value
Methods
AddRelation(int, string, int)
Add specified relation.
public static void AddRelation(int itemListId, string itemId, int sortIndex)
Parameters
BuildSearchSqlForItemType(ItemType, string[], bool, bool)
Builds the search SQL for the ItemType.
public static CommandBuilder? BuildSearchSqlForItemType(ItemType itemType, string[] searchItems, bool includeItemTypeName, bool searchInItemLists)
Parameters
itemTypeItemTypeType of the item.
searchItemsstring[]The search items.
includeItemTypeNameboolif set to
true[include item type name].searchInItemListsbool
Returns
ClearCache(int)
Clears the cache for item list.
public static void ClearCache(int id)
Parameters
idint
Copy(int, ItemRelationListEditor)
Creates a copy of list by its Id.
public static int Copy(int id, ItemRelationListEditor editor)
Parameters
idintItemList Id.
editorItemRelationListEditor
Returns
- int
The id of new list.
Delete(int)
Delete specified list.
public override void Delete(int itemListId)
Parameters
itemListIdintThe item list identifier.
DeleteRelation(int, string)
Delete specified relation.
public static void DeleteRelation(int itemListId, string itemId)
Parameters
DeleteRelations(int)
Delete all itemlist relations.
public static void DeleteRelations(int itemListId)
Parameters
itemListIdint
DeleteWithRelations(bool)
Delete list with relations.
public void DeleteWithRelations(bool deleteItems)
Parameters
deleteItemsboolDelete related item entries or not.
Fill(IDataReader)
Fills object properties with data from the given IDataReader object.
public override void Fill(IDataReader reader)
Parameters
readerIDataReaderReader to read data from.
FillRow(DataRow)
Fills the given DataRow object with object state values.
protected override void FillRow(DataRow row)
Parameters
rowDataRowRow to write data into.
GetItemListById(int)
Returns the ItemList by its Id.
public static ItemList? GetItemListById(int id)
Parameters
idintItemList Id.
Returns
- ItemList
A ItemList with the given Id or null (Nothing in Visual Basic) if the ItemList with the given Id doesn't exist.
ItemHasItemRelatedList(string)
public static bool ItemHasItemRelatedList(string itemTypeName)
Parameters
itemTypeNamestring
Returns
Save()
Saves current data to the data base.
public override void Save()
SaveRelations(IEnumerable<string>, bool, int)
Saves only specified relations.
public void SaveRelations(IEnumerable<string> itemIds, bool recreateRelations = true, int startIndex = 0)
Parameters
itemIdsIEnumerable<string>recreateRelationsboolstartIndexint
SearchRelatedItems(ItemType, int, string, string, string, int)
Gets related items for list by search query.
public static IEnumerable<ItemEntry> SearchRelatedItems(ItemType itemType, int itemListId, string searchQuery, string sortBy, string sortOrder, int topLimit)
Parameters
itemTypeItemTypeType of the item.
itemListIdintThe item list identifier.
searchQuerystringThe search query.
sortBystringThe sort by.
sortOrderstringThe sort order.
topLimitintThe top limit.
Returns
SearchRelatedItems(ItemType, int, string, string, string, int, int, int, ref int)
Gets related items for list by search query.
public static IEnumerable<ItemEntry> SearchRelatedItems(ItemType itemType, int itemListId, string searchQuery, string sortBy, string sortOrder, int topLimit, int pageNumber, int pageSize, ref int totalItems)
Parameters
itemTypeItemTypeType of the item.
itemListIdintThe item list identifier.
searchQuerystringThe search query.
sortBystringThe sort by.
sortOrderstringThe sort order.
topLimitintThe top limit.
pageNumberintThe page index.
pageSizeintThe page size.
totalItemsintTotal items count.
Returns
Remarks
If top limit > 0, then paging settings will not take any effect