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
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
itemTypeItemType- Type of the item.
searchItemsstring[]- The search items.
includeItemTypeNamebool- if 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
idint- ItemList Id.
editorItemRelationListEditor
Returns
- int
- The id of new list.
Copy(int, IDbConnection, IDbTransaction, ItemRelationListEditor)
[Obsolete("Use overload without connection and transaction")]
public static int Copy(int id, IDbConnection connection, IDbTransaction transaction, ItemRelationListEditor editor)
Parameters
idintconnectionIDbConnectiontransactionIDbTransactioneditorItemRelationListEditor
Returns
Delete(int)
Delete specified list.
public override void Delete(int itemListId)
Parameters
itemListIdint- The 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
deleteItemsbool- Delete related item entries or not.
Fill(IDataReader)
Fills object properties with data from the given IDataReader object.
public override void Fill(IDataReader reader)
Parameters
readerIDataReader- Reader to read data from.
FillRow(DataRow)
Fills the given DataRow object with object state values.
protected override void FillRow(DataRow row)
Parameters
rowDataRow- Row to write data into.
GetItemListById(int)
Returns the ItemList by its Id.
public static ItemList GetItemListById(int id)
Parameters
idint- ItemList 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.
isItemHasItemRelatedList(string)
Checks if there is any item list ralated to given item type.
[Obsolete("Use ItemHasItemRelatedList instead")]
public static bool isItemHasItemRelatedList(string itemTypeName)
Parameters
itemTypeNamestring- item type system name.
Returns
- bool
- A ItemList with the given itemTypeName 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()
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
itemTypeItemType- Type of the item.
itemListIdint- The item list identifier.
searchQuerystring- The search query.
sortBystring- The sort by.
sortOrderstring- The sort order.
topLimitint- The 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
itemTypeItemType- Type of the item.
itemListIdint- The item list identifier.
searchQuerystring- The search query.
sortBystring- The sort by.
sortOrderstring- The sort order.
topLimitint- The top limit.
pageNumberint- The page index.
pageSizeint- The page size.
totalItemsint- Total items count.
Returns
Remarks
If top limit > 0, then paging settings will not take any effect