File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/App_Code/Pux/Utils/CustomTableTools.cs
using CMS.CustomTables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Pux.Utils
{
public class CustomTableTools
{
/// <summary>
/// Returns custom table items based on their values, such as ID or GUID.
/// Useful when translating Kentico multiple choice values back to its original data.
/// Example: GetItemsByValue<MyCustomTableInfo>("myUniqueField", "value1|value2")
/// </summary>
/// <typeparam name="T">Type of custom table</typeparam>
/// <param name="column">Column name in custom table</param>
/// <param name="values">Values separated by '|' (e.g. "10|20|30", "one|two|three")</param>
/// <returns></returns>
public static List<T> GetItemsByValue<T>(string column, string values) where T : CustomTableItem, new()
{
if (values == null)
return new List<T>();
return CustomTableItemProvider.GetItems<T>().WhereIn(column, values.Split('|')).ToList();
}
}
}