Class ItemList
- Namespace
- Dynamicweb.Content.Items
- Assembly
- Dynamicweb.dll
ItemList holds the item relations.
- Inheritance
-
Item
List
- Inherited Members
Examples
using Dynamicweb.Content.Items;
namespace Dynamicweb.Examples.Items
{
class ItemListSample
{
void CreteNewList()
{
// Add items to a new list
var list = new ItemList("ExampleNewsItem");
list.Relations = ItemServiceSample.CreateItems();
list.Save();
}
void ManageSavedList(int listId)
{
var 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);
}
void DeleteList(int listId)
{
var list = ItemList.GetItemListById(listId);
// Delete a list, its relations and related items(if parameter = true)
list.DeleteWithRelations(true);
}
}
}
Constructors
ItemList()
ItemList(string)
Parameters
itemType
string
Properties
IsChangedOnLanguage
Gets or sets the flag that list on a language differs from master
Property Value
ItemType
Gets or sets the type of the related items.
Property Value
Relations
Gets or sets the related items.
Property Value
SortBy
Gets or sets the field to sort the items
Property Value
SortOrder
Gets or sets the sort order
Property Value
Methods
AddRelation(int, string, int)
Add specified relation.
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
itemType
ItemType Type of the item.
searchItems
string[]The search items.
includeItemTypeName
boolif set to
true
[include item type name].searchInItemLists
bool
Returns
ClearCache(int)
Clears the cache for item list.
Parameters
id
int
Copy(int, ItemRelationListEditor)
Creates a copy of list by its Id.
Parameters
id
intItemList Id.
editor
ItemRelation List Editor
Returns
- int
The id of new list.
Delete(int)
Delete specified list.
Parameters
itemListId
intThe item list identifier.
DeleteRelation(int, string)
Delete specified relation.
Parameters
DeleteRelations(int)
Delete all itemlist relations.
Parameters
itemListId
int
DeleteWithRelations(bool)
Delete list with relations.
Parameters
deleteItems
boolDelete related item entries or not.
Fill(IDataReader)
Fills object properties with data from the given IData
Parameters
reader
IDataReader Reader to read data from.
FillRow(DataRow)
Fills the given Data
Parameters
row
DataRow Row to write data into.
GetItemListById(int)
Returns the ItemList by its Id.
Parameters
id
intItemList Id.
Returns
- Item
List A ItemList with the given Id or null (Nothing in Visual Basic) if the ItemList with the given Id doesn't exist.
ItemHasItemRelatedList(string)
Parameters
itemTypeName
string
Returns
Save()
Saves current data to the data base.
SaveRelations(IEnumerable<string>, bool, int)
Saves only specified relations.
public void SaveRelations(IEnumerable<string> itemIds, bool recreateRelations = true, int startIndex = 0)
Parameters
itemIds
IEnumerable<string>recreateRelations
boolstartIndex
int
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
itemType
ItemType Type of the item.
itemListId
intThe item list identifier.
searchQuery
stringThe search query.
sortBy
stringThe sort by.
sortOrder
stringThe sort order.
topLimit
intThe 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
itemType
ItemType Type of the item.
itemListId
intThe item list identifier.
searchQuery
stringThe search query.
sortBy
stringThe sort by.
sortOrder
stringThe sort order.
topLimit
intThe top limit.
pageNumber
intThe page index.
pageSize
intThe page size.
totalItems
intTotal items count.
Returns
Remarks
If top limit > 0, then paging settings will not take any effect