Class CustomItem
Base class for custom data objects, which extend the ITypedItem for use in Razor Components.
[PublicApi]
public class CustomItem : ITypedItem, ITyped, IEquatable<ITypedItem>, ICanWrap<ITypedItem>, ICanWrapData, IMultiWrapper<IEntity>
  - Inheritance
 - 
      objectCustomItem
 
- Implements
 
Examples
Usage ca. like this:
- A custom data model in 
AppCode.Datawhich inherits from this class (usually generated by 2sxc Copilot) - Razor code which uses it to convert typed items into this custom data model
 
Example trivial custom ITyped data model:
namespace AppCode.Data
{
  class MyPerson : Custom.Data.CustomItem
  {
    // New custom property
    public string Name => _item.String("Name");
  }
}
Example usage in Razor:
@inherits Custom.Hybrid.RazorTyped
@using AppCode.Data
@{
  var person = As<MyPerson>(MyItem);
}
@* Now you can use the custom properties *@
<span>@person.Name</span>
@* But also all the standard properties like Id, Guid, Title, Type, etc. *@
<span>@person.Id / @person.Guid</span>
  Remarks
It is used by 2sxc Copilot when generating base classes for custom data objects.
History
- Released in v17.06
 - It's not abstract, even if the most common case is to inherit, as there are cases where you want to use it directly.
 
Properties
Guid
The guid of the underlying entity.
[JsonPropertyOrder(-99)]
public Guid Guid { get; }
  Property Value
Remarks
If the entity doesn't exist, it will return an empty guid
Id
The ID of the underlying entity. Use it for edit-functionality or just to have a unique number for this item.
[JsonPropertyOrder(-100)]
public int Id { get; }
  Property Value
Remarks
If the entity doesn't exist, it will return 0
IsDemoItem
Many templates show demo data.
If the template code must know if it's the demo item or
real data, use .IsDemoItem.
[JsonIgnore]
public bool IsDemoItem { get; }
  Property Value
- bool
 True if this is the item configured in the view-settings, false if not.
IsPublished
True if this item version is published. This means that the item can exist as published, or published-with-draft, showing the published version.
Note that by default, end-users only see the published version and don't see any draft version.
[JsonIgnore]
public bool IsPublished { get; }
  Property Value
Remarks
New in v17, see also Publishing
Metadata
Metadata of the current item, with special features.
[JsonIgnore]
public ITypedMetadata Metadata { get; }
  Property Value
Remarks
Added in 16.02
Presentation
The presentation item or null if it doesn't exist.
[JsonIgnore]
public ITypedItem? Presentation { get; }
  Property Value
Publishing
[JsonIgnore]
public IPublishing Publishing { get; }
  Property Value
Title
The title of this item. This is always available no matter what the underlying field for the title is.
[JsonIgnore]
public string? Title { get; }
  Property Value
- string
 The title of the underlying entity. In rare cases where no title-field is known, it can be null. It can also be null if there is no underlying entity.
Remarks
This returns a string which is usually what's expected. In previous versions (before v15) 2sxc it returned an object.
Type
The Content-Type of the current entity.
[JsonIgnore]
public IContentType Type { get; }
  Property Value
_item
The item - for inheriting classes to access.
protected ITypedItem _item { get; }
  Property Value
Remarks
- this property is protected, not public, as it should only be used internally.
 - this also prevents it from being serialized in JSON, which is good.
 - it uses an unusual name 
_itemto avoid naming conflicts with properties generated in inheriting classes. 
Methods
AsList<T>(IEnumerable<ITypedItem>?, NoParamOrder, bool)
Convert a list of Entities or TypedItems into a strongly typed list.
Typically, the type will be from your AppCode.Data.
protected IEnumerable<T> AsList<T>(IEnumerable<ITypedItem>? source, NoParamOrder protector = default, bool nullIfNull = false) where T : class, ICanWrapData
  Parameters
sourceIEnumerable<ITypedItem>protectorNoParamOrdernullIfNullbool
Returns
- IEnumerable<T>
 
Type Parameters
T
Remarks
New in v17.03
As<T>(ITypedItem)
Convert an Entity or TypedItem into a strongly typed object.
Typically, the type will be from your AppCode.Data.
protected T As<T>(ITypedItem item) where T : class, ICanWrapData
  Parameters
itemITypedItem
Returns
- T
 
Type Parameters
T
Remarks
New in v17.03
Attribute(string, NoParamOrder, string?, bool?)
Return a value as a raw HTML string for using inside an attribute.
Usage like title='@item.Attribute("Title")'
It will do a few things such as:
- Ensure dates are in the ISO format
 - Ensure numbers are in a neutral format such as 
14.27and never14,27 - Html encode any characters which would cause trouble such as quotes
 
public IRawHtmlString? Attribute(string name, NoParamOrder noParamOrder = default, string? fallback = null, bool? required = null)
  Parameters
namestringName of the property
noParamOrderNoParamOrderfallbackstringValue to use if the property specified by
namedoesn't existrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- IRawHtmlString
 
Bool(string, NoParamOrder, bool, bool?)
Get a property and return the value as a bool.
If conversion fails, will return default false or what is specified in the fallback.
public bool Bool(string name, NoParamOrder noParamOrder = default, bool fallback = false, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackbooloptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- bool
 Value as
bool
Child(string, NoParamOrder, bool?, GetRelatedOptions?)
A single item from a field.
public ITypedItem? Child(string name, NoParamOrder noParamOrder = default, bool? required = null, GetRelatedOptions? options = null)
  Parameters
namestringName of the field
noParamOrderNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name ChecksoptionsGetRelatedOptions
Returns
- ITypedItem
 The ITypedItem. If the field doesn't exist or is empty, will return null.
Child<T>(string, NoParamOrder, bool?, GetRelatedOptions?)
Get a child and return with specified custom type.
public T? Child<T>(string name, NoParamOrder protector = default, bool? required = null, GetRelatedOptions? options = null) where T : class, ICanWrapData, new()
  Parameters
namestringName of the field
protectorNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name ChecksoptionsGetRelatedOptions
Returns
- T
 
Type Parameters
T
Remarks
New v17.05
Children(string?, NoParamOrder, string?, bool?, GetRelatedOptions?)
A typed list of sub-items. Important for LINQ style querying or just
working with various lists. Note that for getting child items of this item you
can just use the properties, like content.Authors. 
But using Children("Authors", type: typeName) gives you the ability to restrict to a type.  
Please check the tutorials on 2sxc.org/dnn-tutorials/ for more info.
public IEnumerable<ITypedItem> Children(string? field, NoParamOrder noParamOrder = default, string? type = null, bool? required = null, GetRelatedOptions? options = null)
  Parameters
fieldstringOptional field filter - would only return items that point to the current item in a specific field name.
noParamOrderNoParamOrdertypestringOptional type filter - would only return items of this type.
requiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name ChecksoptionsGetRelatedOptions
Returns
- IEnumerable<ITypedItem>
 A list of all items pointing here (filtered), converted to DynamicEntity for convenience.
Remarks
Note that the parameter-order is reversed to the Parents()
Children<T>(string?, NoParamOrder, string?, bool?, GetRelatedOptions?)
A strongly typed list of sub-items. Important for LINQ style querying or just
working with various lists. Note that for getting child items of this item you
can just use the properties, like content.Authors. 
But using Children("Authors", type: typeName) gives you the ability to restrict to a type.  
Please check the tutorials on 2sxc.org/dnn-tutorials/ for more info.
public IEnumerable<T> Children<T>(string? field, NoParamOrder protector = default, string? type = null, bool? required = null, GetRelatedOptions? options = null) where T : class, ICanWrapData, new()
  Parameters
fieldstringName of the field
protectorNoParamOrdertypestringOptional type filter - would only return items of this type.
requiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name ChecksoptionsGetRelatedOptions
Returns
- IEnumerable<T>
 
Type Parameters
T
Remarks
New v17.05
Never null, unless explicitly requested with nullIfNull, otherwise it would return an empty list.
ContainsKey(string)
Check if this typed object has a property of this specified name. It's case-insensitive.
public bool ContainsKey(string name)
  Parameters
namestringthe name like
Image; some objects also support path to sub-property likeAuthor.Name
Returns
Remarks
Adding in 16.03 (WIP)
DateTime(string, NoParamOrder, DateTime, bool?)
Get a property and return the value as a DateTime.
If conversion fails, will return default 0001-01-01 or what is specified in the fallback.
public DateTime DateTime(string name, NoParamOrder noParamOrder = default, DateTime fallback = default, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackDateTimeoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- DateTime
 Value as
DateTime
Decimal(string, NoParamOrder, decimal, bool?)
Get a property and return the value as a decimal.
If conversion fails, will return default 0 or what is specified in the fallback.
public decimal Decimal(string name, NoParamOrder noParamOrder = default, decimal fallback = 0, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackdecimaloptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- decimal
 Value as
decimal
Double(string, NoParamOrder, double, bool?)
Get a property and return the value as a double.
If conversion fails, will return default 0 or what is specified in the fallback.
public double Double(string name, NoParamOrder noParamOrder = default, double fallback = 0, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackdoubleoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- double
 Value as
double
Equals(object?)
Ensure that the equality check is done correctly. If two objects wrap the same item, they will be considered equal.
public override bool Equals(object? b)
  Parameters
bobject
Returns
Field(string, NoParamOrder, bool?)
Get a special info-object describing a specific field in this item. This is a rich object used by other operations which need a lot of context about the item and the field.
public IField? Field(string name, NoParamOrder noParamOrder = default, bool? required = null)
  Parameters
namestringName of the property
noParamOrderNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name Checks
Returns
File(string, NoParamOrder, bool?)
Get the file of the current field. There are a few scenarios:
- If it's a file/hyperlink field pointing to a file such as 
file:27it will retrieve the file itself. - If it's a file/hyperlink field pointing to a url such as 
http://xyzit will returnnull. - If it's a library field, it will just take the first file, as there is no value referencing a specific field
 - If it's any other field, will return 
null 
public IFile? File(string name, NoParamOrder noParamOrder = default, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name Checks
Returns
Remarks
Added in 16.02
Float(string, NoParamOrder, float, bool?)
Get a property and return the value as a float.
If conversion fails, will return default 0 or what is specified in the fallback.
public float Float(string name, NoParamOrder noParamOrder = default, float fallback = 0, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackfloatoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- float
 Value as
float
Folder(string, NoParamOrder, bool?)
Get the ADAM (Automatic Digital Asset Manager) for this field. This is a folder which contains all the files and possibly folders which are uploaded on exactly this field.
public IFolder? Folder(string name, NoParamOrder noParamOrder = default, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- IFolder
 The Folder object
Remarks
Added in 16.02
Get(string, NoParamOrder, bool?, string?)
Get a property.
public object? Get(string name, NoParamOrder noParamOrder = default, bool? required = null, string? language = null)
  Parameters
namestringthe property name like
Image- or path to sub-property likeAuthor.Name(new v15)noParamOrderNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name CheckslanguagestringOptional language like
de,de-chorde,ento determine which values to check. Will ignore languages not in the data model. On items that don't have ML data it will be ignored. new v17.10
Returns
- object
 The result if found or null; or error if the object is in strict mode
Remarks
- parameter 
languagesadded in 17.10 
Get<TValue>(string, NoParamOrder, TValue?, bool?, string?)
Get a value using the name - and cast it to the expected strong type. For example to get an int even though it's stored as decimal.
Since the parameter fallback determines the type TValue you can just write this like
`something.Get("Title", fallback: "no title")
public TValue? Get<TValue>(string name, NoParamOrder noParamOrder = default, TValue? fallback = default, bool? required = null, string? language = null)
  Parameters
namestringthe property name like
Image- or path to sub-property likeAuthor.Name(new v15)noParamOrderNoParamOrderfallbackTValuethe fallback value to provide if not found
requiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name CheckslanguagestringOptional language like
de,de-chorde,ento determine which values to check. Will ignore languages not in the data model. On items that don't have ML data it will be ignored. new v17.10
Returns
- TValue
 The typed value, or the
defaultlikenullor0if casting isn't possible.
Type Parameters
TValueThe expected type, like
string,int, etc. Note that you don't need to specify it, if you specify thefallbackproperty.
Remarks
- Added in v15
 - parameter 
languagesadded in 17.10 
Gps(string, NoParamOrder, bool?)
Get the GPS coordinates of a GPS field as a typed object.
public GpsCoordinates Gps(string name, NoParamOrder protector = default, bool? required = null)
  Parameters
namestringName of a field
protectorNoParamOrderrequiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name Checks
Returns
Remarks
New in v17.03
Html(string, NoParamOrder, object?, bool?, object?, bool?, bool, Func<ITweakInput<string>, ITweakInput<string>>?)
Show a field in the expected / best possible way. As of now it's meant for WYSIWYG fields with Very-Rich Text. See DynamicEntity / TypedItem .Html(...) Method new v16.01
public IHtmlTag? Html(string name, NoParamOrder noParamOrder = default, object? container = null, bool? toolbar = null, object? imageSettings = null, bool? required = null, bool debug = false, Func<ITweakInput<string>, ITweakInput<string>>? tweak = null)
  Parameters
namestringthe field name
noParamOrderNoParamOrdercontainerobjectA wrapper tag for the result. It's either a RazorBlade tag such as
Kit.HtmlTag.Div(), a string such asspanor an empty string `` to indicate no container. If not set it will default to to a div-tag. See docstoolbarbool?Override default toolbar behavior on this field. See docs
imageSettingsobjectSettings for resizing. Default is
Wysiwygbut it can also beContentor a settings object.requiredbool?throw error if
namedoesn't exist, see Convention: Property Required Name ChecksdebugboolActivate debug visualization to better see alignments and such.
tweakFunc<ITweakInput<string>, ITweakInput<string>>tweak behavior - ATM modify the input before it's processed new in v17
Returns
Remarks
- Added in 2sxc 16.01
 - Added 
tweakin v17 - Only works on Razor files inheriting from Hybrid14 or newer
 
Img(string, NoParamOrder, Func<ITweakMedia, ITweakMedia>?, object?, object?, object?, string?, string?, string?, object?, object?, object?)
Get a Responsive Picture object which you can then either just show, or use to construct a more customized output as you need it.
The resulting object can just be added to the html, like @pic or you can work with sub-properties as specified in the IResponsivePicture.
Important: This call only allows you to set the most common parameters factor and width.
For other parameters like height, aspectRatio, quality etc. create typed Settings Settings(object?, NoParamOrder, Func<ITweakResize, ITweakResize>?, object?, object?, object?, object?, string?, string?, string?, object?, string?, object?) and pass them in.
Note
This is the similar as using the Picture(object?, object?, NoParamOrder, Func<ITweakMedia, ITweakMedia>?, object?, object?, string?, string?, string?, object?, string?, object?, object?, object?) just a bit simpler.
An important difference is that it returns null if the field does not exist or is empty, allowing you to just show nothing or use ...Picture(...) ?? someFallback;
public IResponsiveImage? Img(string name, NoParamOrder noParamOrder = default, Func<ITweakMedia, ITweakMedia>? tweak = null, object? settings = null, object? factor = null, object? width = null, string? imgAlt = null, string? imgAltFallback = null, string? imgClass = null, object? imgAttributes = null, object? toolbar = null, object? recipe = null)
  Parameters
namestringName of a field
noParamOrderNoParamOrdertweakFunc<ITweakMedia, ITweakMedia>Tweak API to configure everything (new v18.03). This is recommended above using parameter names and all newer parameters will only be available on this.
settingsobject- The name of a settings configuration, like "Content", "Screen", "Square", etc.
 - A standardized Image-Settings object like Settings.Child("Images.Content") - see https://go.2sxc.org/settings
 - A dynamic object containing settings properties (this can also be a merged custom + standard settings)
 - A strictly typed IResizeSettings object containing all settings created using ResizeSettings
 
factorobjectAn optional multiplier, usually used to create urls which resize to a part of the default content-size. Like 0.5.
widthobjectAn optional, fixed width of the image
imgAltstringOptional
altattribute on the createdimgtag for SEO etc. If supplied, it takes precedence to the alt-description in the image metadata which the editor added themselves. If you want to provide a fallback value (in case the metadata has no alt), useimgAltFallbackimgAltFallbackstringOptional
altattribute which is only used if theimgAltor the alt-text in the metadata are empty.imgClassstringOptional
classattribute on the createdimgtagimgAttributesobjectOptional additional attributes - as anonymous object like
new { style = "padding: 10px" }or Dictionary (new 16.07)toolbarobjectProvide a custom toolbar or
falseto not show a toolbarrecipeobjectOptional recipe = instructions how to create the various variants of this link. Can be any one of these:
- string containing variants
 - Rule object
 
TODO: DOCS not quite ready
Returns
- IResponsiveImage
 - A IResponsivePicture object which can be rendered directly. See Responsive Images API in .net
 - If the field does not exist, it will return 
null - If the field exists, but is empty, it will return 
null 
Remarks
- Added to ITypedItem in v17.04 (previously only Picture was available)
 tweakadded in 18.03
Int(string, NoParamOrder, int, bool?)
Get a property and return the value as a int.
If conversion fails, will return default 0 or what is specified in the fallback.
public int Int(string name, NoParamOrder noParamOrder = default, int fallback = 0, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackintoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- int
 Value as
int
IsEmpty(string, NoParamOrder, string?)
Check if this typed object has a property of this specified name, and has real data.
The opposite version of this is IsNotEmpty(...)
Important
This method is optimized for use in Razor-like scenarios. It's behavior is super-useful but maybe not always expected.
- If the value is a string, and is empty or only contains whitespace (even 
 ) it is regarded as empty. - If the returned value is an empty list (e.g. a field containing relationships, without any items in it) it is regarded as empty.
 
If you need a different kind of check, just .Get(...) the value and perform the checks in your code.
public bool IsEmpty(string name, NoParamOrder noParamOrder = default, string? language = null)
  Parameters
namestringthe property name like
Image; some objects also support path to sub-property likeAuthor.NamenoParamOrderNoParamOrderlanguagestringOptional language like
de,de-chorde,ento determine which values to check. Will ignore languages not in the data model. On items that don't have ML data it will be ignored. new v17.10
Returns
- bool
 trueif the property exists and has a real value. If it returned an empty list, it will also returnfalse
Remarks
- Added in 16.03
 languageparameter added in 17.10
IsNotEmpty(string, NoParamOrder, string?)
Check if this typed object has a property of this specified name, and has real data.
The opposite version of this is IsEmpty(...)
Important
This method is optimized for use in Razor-like scenarios. It's behavior is super-useful but maybe not always expected.
- If the value is a string, and is empty or only contains whitespace (even 
 ) it is regarded as empty. - If the returned value is an empty list (e.g. a field containing relationships, without any items in it) it is regarded as empty.
 
If you need a different kind of check, just .Get(...) the value and perform the checks in your code.
public bool IsNotEmpty(string name, NoParamOrder noParamOrder = default, string? language = null)
  Parameters
namestringthe property name like
Image; some objects also support path to sub-property likeAuthor.NamenoParamOrderNoParamOrderlanguagestringOptional language like
de,de-chorde,ento determine which values to check. Will ignore languages not in the data model. On items that don't have ML data it will be ignored. new v17.10
Returns
- bool
 trueif the property exists and has a real value. If it returned an empty list, it will also returnfalse
Remarks
- Added in 16.03
 languageparameter added in 17.10
Keys(NoParamOrder, IEnumerable<string>?)
Get all the keys available in this Model (all the parameters passed in). This is used to sometimes run early checks if all the expected parameters have been provided.
public IEnumerable<string> Keys(NoParamOrder noParamOrder = default, IEnumerable<string>? only = null)
  Parameters
noParamOrderNoParamOrderonlyIEnumerable<string>Only return the keys specified here, if found. Typical use:
only: new [] { "Key1", "Key2" }. Useful to check if all or any specific keys exist.
Returns
Remarks
Added in 16.03
Long(string, NoParamOrder, long, bool?)
Get a property and return the value as a long.
If conversion fails, will return default 0 or what is specified in the fallback.
public long Long(string name, NoParamOrder noParamOrder = default, long fallback = 0, bool? required = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbacklongoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- long
 Value as
long
Parent(NoParamOrder, bool?, string?, string?, GetRelatedOptions?)
Get either the current parent or the first parent which would be found on .Parents(...).
public ITypedItem? Parent(NoParamOrder noParamOrder = default, bool? current = null, string? type = null, string? field = null, GetRelatedOptions? options = null)
  Parameters
noParamOrderNoParamOrdercurrentbool?if set to
true, will get the Item which created the current item (the parent) which called.Child(...)or.Children(...)typestringOptional type filter - would only return items of this type.
fieldstringOptional field filter - would only return items that point to the current item in a specific field name.
optionsGetRelatedOptions
Returns
- ITypedItem
 either the current parent or the first parent returned by the same
.Parents(...)call.
Parent<T>(NoParamOrder, bool?, string?, string?, GetRelatedOptions?)
Get either the current parent or the first parent which would be found on .Parents(...) as strongly typed.
public T? Parent<T>(NoParamOrder protector = default, bool? current = null, string? type = null, string? field = null, GetRelatedOptions? options = null) where T : class, ICanWrapData, new()
  Parameters
protectorNoParamOrdercurrentbool?if set to
true, will get the Item which created the current item (the parent) which called.Child(...)or.Children(...)typestringOptional type filter - would only return items of this type.
fieldstringOptional field filter - would only return items that point to the current item in a specific field name.
optionsGetRelatedOptions
Returns
- T
 either the current parent or the first parent returned by the same
.Parents(...)call.
Type Parameters
T
Remarks
New v17.06
Parents(NoParamOrder, string?, string?, GetRelatedOptions?)
A typed list of entities which point to this item. Important for LINQ style querying or just
working with various lists. Note that for getting child items of this item you
can just use the properties, like content.Authors. 
Please check the tutorials on 2sxc.org/dnn-tutorials/ for more info.
public IEnumerable<ITypedItem> Parents(NoParamOrder noParamOrder = default, string? type = null, string? field = null, GetRelatedOptions? options = null)
  Parameters
noParamOrderNoParamOrdertypestringOptional type filter - would only return items of this type.
fieldstringOptional field filter - would only return items that point to the current item in a specific field name.
optionsGetRelatedOptions
Returns
- IEnumerable<ITypedItem>
 A list of all items pointing here (filtered), converted to DynamicEntity for convenience.
Remarks
Note that the parameter-order is reversed to the Children()
Parents<T>(NoParamOrder, string?, string?, GetRelatedOptions?)
A typed list of entities which point to this item. Important for LINQ style querying or just
working with various lists. Note that for getting child items of this item you
can just use the properties, like content.Authors. 
Please check the tutorials on 2sxc.org/dnn-tutorials/ for more info.
public IEnumerable<T> Parents<T>(NoParamOrder protector = default, string? type = null, string? field = null, GetRelatedOptions? options = null) where T : class, ICanWrapData, new()
  Parameters
protectorNoParamOrdertypestringOptional type filter - would only return items of this type. If not specified (null) will use the name of T.
fieldstringOptional field filter - would only return items that point to the current item in a specific field name.
optionsGetRelatedOptions
Returns
- IEnumerable<T>
 A list of all items pointing here (filtered), converted to DynamicEntity for convenience.
Type Parameters
T
Remarks
Note that the parameter-order is reversed to the Children()
Picture(string, NoParamOrder, Func<ITweakMedia, ITweakMedia>?, object?, object?, object?, string?, string?, string?, object?, string?, object?, object?, object?)
Get a Responsive Picture object which you can then either just show, or use to construct a more customized output as you need it.
The resulting object can just be added to the html, like @pic or you can work with sub-properties as specified in the IResponsivePicture.
Important: This call only allows you to set the most common parameters factor and width.
For other parameters like height, aspectRatio, quality etc. create typed Settings Settings(object?, NoParamOrder, Func<ITweakResize, ITweakResize>?, object?, object?, object?, object?, string?, string?, string?, object?, string?, object?) and pass them in.
Note
This is the similar as using the Picture(object?, object?, NoParamOrder, Func<ITweakMedia, ITweakMedia>?, object?, object?, string?, string?, string?, object?, string?, object?, object?, object?) just a bit simpler.
An important difference is that it returns null if the field does not exist or is empty, allowing you to just show nothing or use ...Picture(...) ?? someFallback;
public IResponsivePicture? Picture(string name, NoParamOrder noParamOrder = default, Func<ITweakMedia, ITweakMedia>? tweak = null, object? settings = null, object? factor = null, object? width = null, string? imgAlt = null, string? imgAltFallback = null, string? imgClass = null, object? imgAttributes = null, string? pictureClass = null, object? pictureAttributes = null, object? toolbar = null, object? recipe = null)
  Parameters
namestringName of a field
noParamOrderNoParamOrdertweakFunc<ITweakMedia, ITweakMedia>Tweak API to configure everything (new v18.03). This is recommended above using parameter names and all newer parameters will only be available on this.
settingsobject- The name of a settings configuration, like "Content", "Screen", "Square", etc.
 - A standardized Image-Settings object like Settings.Child("Images.Content") - see https://go.2sxc.org/settings
 - A dynamic object containing settings properties (this can also be a merged custom + standard settings)
 - A strictly typed IResizeSettings object containing all settings created using ResizeSettings
 
factorobjectAn optional multiplier, usually used to create urls which resize to a part of the default content-size. Like 0.5.
widthobjectAn optional, fixed width of the image
imgAltstringOptional
altattribute on the createdimgtag for SEO etc. If supplied, it takes precedence to the alt-description in the image metadata which the editor added themselves. If you want to provide a fallback value (in case the metadata has no alt), useimgAltFallbackimgAltFallbackstringOptional
altattribute which is only used if theimgAltor the alt-text in the metadata are empty.imgClassstringOptional
classattribute on the createdimgtagimgAttributesobjectOptional additional attributes - as anonymous object like
new { style = "padding: 10px" }or Dictionary (new 16.07)pictureClassstringOptional
classattribute on the createdpicturetagpictureAttributesobjectOptional additional attributes - as anonymous object like
new { style = "padding: 10px" }or Dictionary (new 16.07)toolbarobjectProvide a custom toolbar or
falseto not show a toolbarrecipeobjectOptional recipe = instructions how to create the various variants of this link. Can be any one of these:
- string containing variants
 - Rule object
 
TODO: DOCS not quite ready
Returns
- IResponsivePicture
 - A IResponsivePicture object which can be rendered directly. See Responsive Images API in .net
 - If the field does not exist, it will return 
null - If the field exists, but is empty, it will return 
null 
Remarks
- Added to ITypedItem in v16.03
 imgAttributes,picClassandpicAttributesadded in 16.07tweakadded in 18.03
String(string, NoParamOrder, string?, bool?, object?)
Get a property and return the value as a string.
If conversion fails, will return default null or what is specified in the fallback.
public string? String(string name, NoParamOrder noParamOrder = default, string? fallback = null, bool? required = null, object? scrubHtml = null)
  Parameters
namestringproperty name
noParamOrderNoParamOrderfallbackstringoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name ChecksscrubHtmlobjectIf
true, will remove all HTML tags from the string. Ifpwill remove allptags, ifdiv,spanwill remove these tags. This is the same as usingKit.Scrub.All(...)or.Only(...). For more detailed scrubbing, use theKit.Scrub`
Returns
- string
 Value as
string
ToString()
Override ToString to give more information about the current object
public override string ToString()
  Returns
Url(string, NoParamOrder, string?, bool?)
Get a url from a field. It will do sanitation / url-corrections for special characters etc.
On TypedItems it will also auto-convert values such as file:72 or page:14.
public string? Url(string name, NoParamOrder noParamOrder = default, string? fallback = null, bool? required = null)
  Parameters
namestringThe field name.
noParamOrderNoParamOrderfallbackstringoptional fallback if conversion fails
requiredbool?throw error if the
namedoesn't exist, see Convention: Property Required Name Checks
Returns
- string
 A url converted if possible. If the field contains anything else such as
hellothen it will not be modified.
Operators
operator ==(CustomItem, CustomItem)
Ensure that the equality check is done correctly. If two objects wrap the same item, they will be considered equal.
public static bool operator ==(CustomItem item1, CustomItem item2)
  Parameters
item1CustomItemfirst item to compare
item2CustomItemsecond item to compare
Returns
- bool
 true, if both wrappers are the same type and wrap the same entity
operator !=(CustomItem, CustomItem)
Ensure that the equality check is done correctly. If two objects wrap the same item, they will be considered equal.
public static bool operator !=(CustomItem item1, CustomItem item2)
  Parameters
item1CustomItemfirst item to compare
item2CustomItemsecond item to compare
Returns
- bool
 false, if both wrappers are the same type and wrap the same entity