Exemple #1
0
        public override string Generate(InsertDataExpression expression)
        {
            if (compatabilityMode == CompatabilityMode.STRICT)
            {
                List <string> unsupportedFeatures = expression.AdditionalFeatures.Keys.Where(x => !IsAdditionalFeatureSupported(x)).ToList();

                if (unsupportedFeatures.Any())
                {
                    string errorMessage =
                        string.Format("The following database specific additional features are not supported in strict mode [{0}]",
                                      expression.AdditionalFeatures.Keys.Aggregate((x, y) => x + ", " + y));
                    return(compatabilityMode.HandleCompatabilty(errorMessage));
                }
            }

            List <string> columnNames   = new List <string>();
            List <string> columnValues  = new List <string>();
            List <string> insertStrings = new List <string>();

            foreach (InsertionDataDefinition row in expression.Rows)
            {
                columnNames.Clear();
                columnValues.Clear();
                foreach (KeyValuePair <string, object> item in row)
                {
                    columnNames.Add(Quoter.QuoteColumnName(item.Key));
                    columnValues.Add(Quoter.QuoteValue(item.Value));
                }

                string columns = String.Join(", ", columnNames.ToArray());
                string values  = String.Join(", ", columnValues.ToArray());
                insertStrings.Add(String.Format(InsertData, Quoter.QuoteTableName(expression.TableName), columns, values));
            }
            return(String.Join("; ", insertStrings.ToArray()));
        }
        private string ValidateAdditionalFeatureCompatibility(IEnumerable <KeyValuePair <string, object> > features)
        {
            if (compatabilityMode == CompatabilityMode.STRICT)
            {
                List <string> unsupportedFeatures =
                    features.Where(x => !IsAdditionalFeatureSupported(x.Key)).Select(x => x.Key).ToList();

                if (unsupportedFeatures.Any())
                {
                    string errorMessage =
                        string.Format(
                            "The following database specific additional features are not supported in strict mode [{0}]",
                            unsupportedFeatures.Aggregate((x, y) => x + ", " + y));
                    {
                        return(compatabilityMode.HandleCompatabilty(errorMessage));
                    }
                }
            }
            return(string.Empty);
        }
 //All Schema method throw by default as only Sql server 2005 and up supports them.
 public override string Generate(CreateSchemaExpression expression)
 {
     return(compatabilityMode.HandleCompatabilty("Schemas are not supported"));
 }