private static bool CheckTableExists(Schema schema) { string sql = string.Format(@"SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}' AND TABLE_TYPE='TABLE'", schema.GetTableName()); SqlCeCommand command = new SqlCeCommand() { CommandText = sql }; return((int)SQLCeHelper.ExecuteScalar(schema.Repository.GetConnectionString(), command) != 0); }
public object ExecuteScalar(Repository repository, string queryText, params KeyValuePair <string, object>[] parameters) { var connectionString = repository.GetConnectionString(); var command = new System.Data.SqlServerCe.SqlCeCommand(queryText); if (parameters != null && parameters.Length > 0) { command.Parameters.AddRange(parameters.Select(it => new System.Data.SqlServerCe.SqlCeParameter() { ParameterName = it.Key, Value = it.Value }).ToArray()); } return(SQLCeHelper.ExecuteScalar(connectionString, command)); }