Class ItemList
- Namespace
- Dynamicweb.Content.Items
- Assembly
- Dynamicweb.dll
ItemList holds the item relations.
public class ItemList : DbObject
- Inheritance
-
ItemList
- 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()
public ItemList()
ItemList(string)
public ItemList(string itemType)
Parameters
itemType
string
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
itemType
ItemTypeType 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.
public static void ClearCache(int id)
Parameters
id
int
Copy(int, ItemRelationListEditor)
Creates a copy of list by its Id.
public static int Copy(int id, ItemRelationListEditor editor)
Parameters
id
intItemList Id.
editor
ItemRelationListEditor
Returns
- int
The id of new list.
Delete(int)
Delete specified list.
public override void Delete(int itemListId)
Parameters
itemListId
intThe 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
itemListId
int
DeleteWithRelations(bool)
Delete list with relations.
public void DeleteWithRelations(bool deleteItems)
Parameters
deleteItems
boolDelete related item entries or not.
Fill(IDataReader)
Fills object properties with data from the given IDataReader object.
public override void Fill(IDataReader reader)
Parameters
reader
IDataReaderReader to read data from.
FillRow(DataRow)
Fills the given DataRow object with object state values.
protected override void FillRow(DataRow row)
Parameters
row
DataRowRow to write data into.
GetItemListById(int)
Returns the ItemList by its Id.
public static ItemList GetItemListById(int id)
Parameters
id
intItemList 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
itemTypeName
string
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
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
ItemTypeType 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
ItemTypeType 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