/// <summary> /// Initializes a new complex Field with required arguments. /// </summary> /// <param name="name">The name of the complex field.</param> /// <param name="dataType">The data type of the field. Must be a complex type.</param> /// <param name="fields">The sub-fields that comprise the complex type. They can be simple or complex fields themselves.</param> /// <exception cref="System.ArgumentException">Thrown if <c>dataType</c> is not a complex type.</exception> /// <exception cref="System.ArgumentNullException">Thrown if <c>fields</c> is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">Thrown if <c>fields</c> is empty.</exception> public Field(string name, DataType dataType, IList <Field> fields) : this() { Throw.IfArgument(!dataType.IsComplex(), nameof(dataType), "Cannot create a complex field of a non-complex type."); Throw.IfArgumentNull(fields, nameof(fields)); Throw.IfArgumentOutOfRange(fields.Count < 1, nameof(fields), "Cannot create a complex field without sub-fields."); Name = name; Type = dataType; Fields = fields; }
/// <summary> /// Initializes a new simple Field with required arguments. /// </summary> /// <param name="name">The name of the simple field.</param> /// <param name="dataType">The data type of the simple field. Cannot be a complex type.</param> /// <exception cref="System.ArgumentException">Thrown if <c>dataType</c> is a complex type.</exception> public Field(string name, DataType dataType) : this() { Throw.IfArgument(dataType.IsComplex(), nameof(dataType), "Cannot create a simple field of a complex type."); Name = name; Type = dataType; // Set all defaults per their SDK-documented values, which differ from the REST API defaults. // This is for backwards compatibility with all prior versions of the Azure Search .NET SDK. IsKey = false; IsRetrievable = true; IsSearchable = false; IsFilterable = false; IsSortable = false; IsFacetable = false; }