Table of Contents

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

bool

ItemType

Gets or sets the type of the related items.
public string ItemType { get; set; }

Property Value

string

Relations

Gets or sets the related items.
public IEnumerable<ItemEntry> Relations { get; set; }

Property Value

IEnumerable<ItemEntry>

SortBy

Gets or sets the field to sort the items
public string SortBy { get; set; }

Property Value

string

SortOrder

Gets or sets the sort order
public string SortOrder { get; set; }

Property Value

string

Methods

AddRelation(int, string, int)

Add specified relation.
public static void AddRelation(int itemListId, string itemId, int sortIndex)

Parameters

itemListId int
itemId string
sortIndex int

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 bool
if set to true [include item type name].
searchInItemLists bool

Returns

CommandBuilder

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 int
ItemList Id.
editor ItemRelationListEditor

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

id int
connection IDbConnection
transaction IDbTransaction
editor ItemRelationListEditor

Returns

int

Delete(int)

Delete specified list.
public override void Delete(int itemListId)

Parameters

itemListId int
The item list identifier.

DeleteRelation(int, string)

Delete specified relation.
public static void DeleteRelation(int itemListId, string itemId)

Parameters

itemListId int
itemId string

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 bool
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

reader IDataReader
Reader to read data from.

FillRow(DataRow)

Fills the given DataRow object with object state values.
protected override void FillRow(DataRow row)

Parameters

row DataRow
Row to write data into.

GetItemListById(int)

Returns the ItemList by its Id.
public static ItemList GetItemListById(int id)

Parameters

id int
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

itemTypeName string
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

itemTypeName string

Returns

bool

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

itemType ItemType
Type of the item.
itemListId int
The item list identifier.
searchQuery string
The search query.
sortBy string
The sort by.
sortOrder string
The sort order.
topLimit int
The top limit.

Returns

IEnumerable<ItemEntry>

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 int
The item list identifier.
searchQuery string
The search query.
sortBy string
The sort by.
sortOrder string
The sort order.
topLimit int
The top limit.
pageNumber int
The page index.
pageSize int
The page size.
totalItems int
Total items count.

Returns

IEnumerable<ItemEntry>

Remarks

If top limit > 0, then paging settings will not take any effect
To top