internal static SQLDMLStatement GetDMLStatement(IDatabaseTenant Tenant, BarDMLScript ScriptId, object [] Parameters)
        {
            SQLDMLScripts dmlScripts = new SQLDMLScripts();

            if (ScriptId == BarDMLScript.eCreateUser)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eCreateUser, Parameters));
            }

            if (ScriptId == BarDMLScript.eCreateInstitution)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eCreateInstitution, Parameters));
            }

            if (ScriptId == BarDMLScript.eCreateToken)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eCreateToken, Parameters));
            }

            if (ScriptId == BarDMLScript.eCreateWallet)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eCreateWallet, Parameters));
            }

            if (ScriptId == BarDMLScript.eCreateTransaction)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eCreateTransaction, Parameters));
            }

            if (ScriptId == BarDMLScript.eDeletUser)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eDeletUser, Parameters));
            }

            if (ScriptId == BarDMLScript.eDeleteInstitution)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eDeleteInstitution, Parameters));
            }

            if (ScriptId == BarDMLScript.eDeleteToken)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eDeleteToken, Parameters));
            }

            if (ScriptId == BarDMLScript.eDeleteWallet)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eDeleteWallet, Parameters));
            }

            if (ScriptId == BarDMLScript.eDeleteTransaction)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eDeleteTransaction, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetUser)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetUser, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetUserByLoginDetails)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetUserByLoginDetails, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetAllUsers)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetAllUsers, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetInstitution)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetInstitution, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetInstitutionByLoginDetails)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetInstitutionByLoginDetails, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetAllInstitutions)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetAllInstitutions, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetToken)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetToken, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetWallet)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetWallet, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetTransaction)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetTransaction, Parameters));
            }

            if (ScriptId == BarDMLScript.eUpdateUser)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eUpdateUser, Parameters));
            }

            if (ScriptId == BarDMLScript.eUpdateInstitution)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eUpdateInstitution, Parameters));
            }

            if (ScriptId == BarDMLScript.eUpdateToken)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eUpdateToken, Parameters));
            }

            if (ScriptId == BarDMLScript.eUpdateWallet)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eUpdateWallet, Parameters));
            }

            if (ScriptId == BarDMLScript.eUpdateTransaction)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eUpdateTransaction, Parameters));
            }

            if (ScriptId == BarDMLScript.eSendTokens)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eSendTokens, Parameters));
            }

            if (ScriptId == BarDMLScript.eGetBalance)
            {
                return(dmlScripts.GetScript(Tenant, BarDMLScript.eGetBalance, Parameters));
            }

            throw new Exception("CODE LOGIC ERROR : " + ScriptId.ToString() + " not in statement list.");
        }
        internal static SQLDMLStatement GetDMLStatementForGenericEntity(IDatabaseTenant Tenant, object Entity, DMLStatemtType dMLStatemtType, List <string> querProperytParametersToUse)
        {
            List <object> propValues = GetObjectPropertyValues(Entity);
            List <string> propNames  = GetObjectPropertyNames(Entity);

            List <ISQLDMLStatementVariable> uniqueKeys = null;

            if (dMLStatemtType == DMLStatemtType.SelectAll && querProperytParametersToUse == null)
            {
                uniqueKeys = new List <ISQLDMLStatementVariable>
                {
                    new SQLDMLStatementVariable {
                        Name = "@Tenant", Value = "TR1"
                    }
                };
            }
            else if (querProperytParametersToUse == null)
            {
                EntityDescriber ed = new EntityDescriber(Entity);
                bool            primaryKeyIdFieldValueSupplied = ed.PrimaryKeyProvidedOnEntity();

                if (primaryKeyIdFieldValueSupplied && (dMLStatemtType == DMLStatemtType.Update || dMLStatemtType == DMLStatemtType.Delete))
                {
                    uniqueKeys = GetUniqueKeyNameValuePairs(Entity, true, false);
                }
                else if (primaryKeyIdFieldValueSupplied == false && (dMLStatemtType == DMLStatemtType.Update || dMLStatemtType == DMLStatemtType.Delete))
                {
                    uniqueKeys = GetUniqueKeyNameValuePairs(Entity, false, true);
                }
                else
                {
                    uniqueKeys = GetUniqueKeyNameValuePairs(Entity, false, true);
                }
            }
            else
            {
                uniqueKeys = GetFilterNameValuePairs(Entity);
            }

            List <ISQLDMLStatementVariable> uniqueKeysFiltered = new List <ISQLDMLStatementVariable>();

            if (querProperytParametersToUse != null)
            {
                querProperytParametersToUse.Add("Tenant");
                foreach (var key in uniqueKeys)
                {
                    if (querProperytParametersToUse.Contains(key.Name.Replace("@", "")))
                    {
                        uniqueKeysFiltered.Add(key);
                    }
                }
            }
            else
            {
                uniqueKeysFiltered = uniqueKeys;
            }


            SQLDMLScripts dmlScripts = new SQLDMLScripts();

            return(dmlScripts.GetInsertScriptForTypedEntity(Tenant, Entity, propNames, propValues, dMLStatemtType, uniqueKeysFiltered));
        }