Ejemplo n.º 1
0
        public IEnumerable <Category> QueryCategories(TextContent content)
        {
            List <Category> list = new List <Category>();
            SqlCeConnection connection;

            using (var dataReader = SQLCeHelper.ExecuteReader(content.GetRepository().GetConnectionString(),
                                                              dbCommands.QueryCategories(content), out connection))
            {
                try
                {
                    while (dataReader.Read())
                    {
                        Category category = new Category()
                        {
                            CategoryFolder = dataReader.GetString(dataReader.GetOrdinal("CategoryFolder")),
                            CategoryUUID   = dataReader.GetString(dataReader.GetOrdinal("CategoryUUID")),
                            ContentUUID    = dataReader.GetString(dataReader.GetOrdinal("UUID")),
                        };
                        list.Add(category);
                    }
                }
                finally
                {
                    dataReader.Close();
                    connection.Close();
                }
            }
            return(list);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        public IEnumerable <IDictionary <string, object> > ExecuteQuery(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());
            }
            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);
        }
Ejemplo n.º 4
0
        public IEnumerable <IDictionary <string, object> > ExportSchemaData(Schema schema)
        {
            var    connectionString = schema.Repository.GetConnectionString();
            string sql = string.Format("SELECT * FROM [{0}] ", schema.GetTableName());
            List <IDictionary <string, object> > list = new List <IDictionary <string, object> >();
            SqlCeConnection connection;

            using (var reader = SQLCeHelper.ExecuteReader(connectionString, new SqlCeCommand()
            {
                CommandText = sql
            }, out connection))
            {
                try
                {
                    while (reader.Read())
                    {
                        list.Add(reader.ToContent <TextContent>(new TextContent()));
                    }
                }
                finally
                {
                    reader.Close();
                    connection.Close();
                }
            }
            return(list);
        }