private bool IsReadIdentityStatement(ProcedureSelectStatement selectStatement) { if (selectStatement == null) { return(false); } foreach (ProcedureStatement statement in selectStatement.Set) { var setStatement = statement as ProcedureSetStatement; if (setStatement == null) { continue; } if (setStatement.RightExpression == null) { continue; } if (setStatement.RightExpression.Function == ProcedureFunctionType.Identity) { return(true); } } return(false); }
private void UpdateProcedures() { foreach (var procedure in Project.Database.Procedures) { ProcedureSelectStatement selectStatement = null; foreach (var enumParameter in procedure.Parameters) { // Find the original parameter var methodParameter = enumParameter.MethodParameter; if (methodParameter == null) { continue; } var originalMethodParameter = methodParameter.GetData(NamespaceUri + ":parameter", (MethodParameter)null); if (originalMethodParameter == null) { continue; } var valueParameter = procedure.Parameters.FirstOrDefault(_ => _.MethodParameter == originalMethodParameter); if (valueParameter == null || valueParameter.Column == null) { continue; } if (selectStatement == null) { // Get the select statement of the procedure // The procedure should contains only one Select statement selectStatement = procedure.Body.Statements.OfType <ProcedureSelectStatement>().FirstOrDefault(); if (selectStatement == null) { return; } } ProcedureExpressionStatement whereStatement = null; foreach (var enumValue in FilterFunctionsEnumeration.Values) { FilterFunctions op = GetFilterFunction(enumValue); if (!IsSupported(op, procedure, valueParameter)) { continue; } ProcedureExpressionStatement testEnumValueStatement = CreateEnumerationEqualsStatement(selectStatement, enumParameter, enumValue); ProcedureExpressionStatement testValueStatement = CreateParameterTestStatement(selectStatement, valueParameter, op); if (testValueStatement == null) { continue; } var paramWhereStatement = new ProcedureExpressionStatement( selectStatement, ProcedureOperationType.And, testEnumValueStatement, testValueStatement); if (whereStatement == null) { whereStatement = paramWhereStatement; } else { whereStatement = new ProcedureExpressionStatement(selectStatement, ProcedureOperationType.Or, whereStatement, paramWhereStatement); } } // Declare the statement as a search expression // Search expression is used by SEARCH method to identify dynamic parts of the body whereStatement.Visit <ProcedureStatement>(statement => { ProcedureExpressionStatement s = statement as ProcedureExpressionStatement; if (s != null) { procedure.MarkSearchExpression(s, valueParameter); if (!s.IsLiteral) { s.SearchExpressionParameter = valueParameter; } } }); selectStatement.AddExpressionToWhere(whereStatement, ProcedureOperationType.And); } } }
private bool IsReadIdentityStatement(ProcedureSelectStatement selectStatement) { if (selectStatement == null) return false; foreach (ProcedureStatement statement in selectStatement.Set) { var setStatement = statement as ProcedureSetStatement; if (setStatement == null) continue; if (setStatement.RightExpression == null) continue; if (setStatement.RightExpression.Function == ProcedureFunctionType.Identity) return true; } return false; }