//****************************************************************************************************** // AdditionalFieldSearchAttribute.cs - Gbtc // // Copyright © 2021, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this // file except in compliance with the License. You may obtain a copy of the License at: // // http://opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 06/12/2021 - C. Lackner // Generated original version of source code. // //****************************************************************************************************** using System; namespace GSF.Data.Model { /// /// Defines an attribute that will allow setting a custom view a modeled table. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] public sealed class AdditionalFieldSearchAttribute : Attribute { /// /// Gets the condition used to reduce the number of rows. /// public string Condition { get; } /// /// Gets Table name to use for AdditionalFields. /// public string AdditionalFieldTable { get; } /// /// Gets Field name to use for matching . /// public string PrimaryKeyField { get; } /// /// Gets Field name to use for matching Values. /// public string ValueField { get; } /// /// Gets Field name to use for matching FieldNames. /// public string FieldKeyField { get; } /// /// Creates a new . /// /// Condition to be true for any row in the additionalFields Table to be used. /// SQL Table containing additional Fields. /// SQL Column that will be matched to . /// SQL Column that will be matched to the Value. /// SQL Column that will be matched to the Field name. public AdditionalFieldSearchAttribute(string condition, string additionalFieldsTable, string primaryKeyCollumn, string valueCollumn, string fieldKeyCollumn) { Condition = condition; AdditionalFieldTable = additionalFieldsTable; PrimaryKeyField = primaryKeyCollumn; ValueField = valueCollumn; FieldKeyField = fieldKeyCollumn; } /// /// Creates a new . /// /// Condition to be true for any row in the additionalFields Table to be used. /// /// This Assumes the following View is set up: /// CREATE VIEW AdditionalFieldSearch AS /// SELECT /// AdditionalFieldValue.ParentTableID, /// AdditionalFieldValue.Value, /// AdditionalField.ParentTable, /// AdditionalField.FieldName, /// FROM /// AdditionalField LEFT JOIN /// AdditionalFieldValue ON AdditionalFieldValue.AdditionalFieldID = AdditionalField.ID /// GO /// public AdditionalFieldSearchAttribute(string condition): this(condition, "AdditionalFieldSearch", "ParentTableID", "Value", "FieldName") { } } }