Exemplo n.º 1
0
 public void ImportCategoryData(Repository repository, IEnumerable<Category> data)
 {
     SQLCeHelper.ExecuteNonQuery(repository.GetConnectionString(),
        data.Select(it => dbCommands.AddCategory(repository, it)).ToArray());
 }
Exemplo n.º 2
0
 public IEnumerable<Category> ExportCategoryData(Repository repository)
 {
     var connectionString = repository.GetConnectionString();
     string sql = string.Format("SELECT UUID,CategoryFolder,CategoryUUID FROM [{0}] ", repository.GetCategoryTableName());
     List<Category> list = new List<Category>();
     SqlCeConnection connection;
     using (var reader = SQLCeHelper.ExecuteReader(connectionString, new SqlCeCommand() { CommandText = sql }, out connection))
     {
         try
         {
             while (reader.Read())
             {
                 Category category = new Category();
                 category.ContentUUID = reader.GetString(0);
                 category.CategoryFolder = reader.GetString(1);
                 category.CategoryUUID = reader.GetString(2);
                 list.Add(category);
             }
         }
         finally
         {
             reader.Close();
             connection.Close();
         }
     }
     return list;
 }
Exemplo n.º 3
0
        public IEnumerable<IDictionary<string, object>> ExecuteQuery(Repository repository, string queryText, System.Data.CommandType commandType = System.Data.CommandType.Text, 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());
            }
            command.CommandType = commandType;
            List<IDictionary<string, object>> list = new List<IDictionary<string, object>>();
            SqlCeConnection connection;
            using (var dataReader = SQLCeHelper.ExecuteReader(connectionString, command, out connection))
            {
                try
                {
                    while (dataReader.Read())
                    {
                        TextContent content = new TextContent();
                        dataReader.ToContent(content);
                        list.Add(content);
                    }
                }
                finally
                {
                    dataReader.Close();
                    connection.Close();
                }
            }
            return list;
        }
Exemplo n.º 4
0
        public object ExecuteScalar(Repository repository, string queryText, System.Data.CommandType commandType = System.Data.CommandType.Text, 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());
            }
            command.CommandType = commandType;
            return SQLCeHelper.ExecuteScalar(connectionString, command);
        }
Exemplo n.º 5
0
 //        private static void CreateMediaContentTable(Repository repository)
 //        {
 //            string ddl = string.Format(@"CREATE TABLE [{0}] (
 //    Id int IDENTITY (100,1),
 //    UUID nvarchar(36) NOT NULL PRIMARY KEY,
 //    UserKey nvarchar(526),
 //    UtcCreationDate datetime,
 //    UtcLastModificationDate datetime,
 //    Published bit,
 //    OriginalUUID nvarchar(36),
 //    FolderName nvarchar(256),
 //    FileName nvarchar(256),
 //    VirtualPath nvarchar(256),
 //    UserId nvarchar(256)
 //    );", repository.GetMediaContentTableName());
 //            ExecuteDDL(repository, ddl);
 //        }
 protected static void ExecuteDDL(Repository repository, string ddl)
 {
     if (!string.IsNullOrEmpty(ddl))
     {
         SQLCeHelper.ExecuteNonQuery(repository.GetConnectionString(),
             ddl.Split(';').Where(it => !string.IsNullOrEmpty(it)).Select(it => new SqlCeCommand(it, null)).ToArray());
     }
 }