예제 #1
0
        private string CheckForPrimaryKey(List <Tuple <Tuple <string, string>, string> > conditionList)
        {
            if (conditionList.Count == 0)
            {
                return("");
            }

            var columnsUsed             = "";
            var primaryKeyColumns       = TableUtils.GetPrimaryKey(DatabaseName, TableName);
            var primaryKeyColumnsString = "";

            foreach (var primaryKey in primaryKeyColumns)
            {
                primaryKeyColumnsString += primaryKey + "_";
            }
            primaryKeyColumnsString = primaryKeyColumnsString.Remove(primaryKeyColumnsString.Length - 1);

            foreach (var column in conditionList)
            {
                columnsUsed += column.Item1.Item2 + "_";
            }

            if (columnsUsed != "")
            {
                columnsUsed = columnsUsed.Remove(columnsUsed.Length - 1);

                if (primaryKeyColumnsString.Contains(columnsUsed))
                {
                    // the primary key of the table can be used if the attributes are a prefix of the attributes in the primary key structure
                    return(columnsUsed);
                }
            }

            return("");
        }