2008年8月小记(SQL2008FileStream特性,Linq-Aggregate,Linq-Dictionary,Linq-OfType, 数据库收缩,WCF-MSMQ,标题闪烁)

1、在SQL2008中启用FileStream特性
(1)、在SSMS中,打开数据库实例的属性窗口,在高级选项卡中将“文件流访问级别”设置为已启用完全访问或者已启用T-SQL访问。然后单击“确定”按钮。

(2)、在配置管理器中将SQL Server服务的FILESTREAM打开
(3)、重启SQL Server服务,然后再还原AdventureWorks2008数据库即可。

 

2、使用Linq将字符串数组转换为以逗号分隔的字符串。

string[] strs = new string[] { "billok""junbiaochen" };
string str = (strs != null && strs.Length != 0? strs.Aggregate((name, next) => name + "," + next) : string.Empty;

 

3、删除某个目录及其所有子目录和文件。del "子目录" /s/q

4、New Dictionary<TKey, TValue>的简写形式:

        public void NewDictionary()
        {
            Dictionary
<string, int> dic = new Dictionary<string, int>()
            {
                {"Alice", 
50},
                {"Bob" , 
40},
                {"Cathy", 
45}
            };
            foreach (KeyValuePair
<string, int> kv in dic)
                OutputTestRow(string.Format("{
0}={1}", kv.Key, kv.Value));
        }

 

5、通过OfType<T>筛选出指定的类型列表

            object[] vals = { 1, "Hello", true, "World", 9.1 };
            IEnumerable
<string> justStrings = vals.OfType<string>();
            foreach (string 
str in justStrings)
            {
                OutputTestRow(
str);//只输出Hello,World
            }
            Response.Output.Write("
<hr/>");

返回"Hello" "World"

 

6、使用脚本收缩数据库。

数据库经过一段时间的添加、更新、删除操作后会使得日志文件变得十分具大,对空间占用很大,同时不利于备份和备份文件的管理,所以有必要定期对数据进行收缩处理,通过SQL Server Agent运行一个定作业,在作业中对数据进行统一的收缩处理是一个比较好的办法。

    USE [master]
    
GO
    
ALTER DATABASE [CJB_Samples] SET RECOVERY SIMPLE WITH NO_WAIT
    
GO
    
ALTER DATABASE [CJB_Samples] SET RECOVERY SIMPLE 
    
GO
    
USE [CJB_Samples]
    
GO
    
DBCC SHRINKFILE (N'CJB_Samples_log' , 0, TRUNCATEONLY)
    
GO

    
USE [master]
    
GO
    
ALTER DATABASE [CJB_Samples] SET RECOVERY FULL WITH NO_WAIT
    
GO
    
ALTER DATABASE [CJB_Samples] SET RECOVERY FULL 
    
GO

 

7、WCF中使用MSMQ,须注意是否使用事务性队列配置是不一样的,如果没有使用事务,请配置 durable="false" exactlyOnce="false" 

8、使网页标题进行闪烁。

        var _IsFlash = false;
        setInterval(
"flash_title()"1500);
        
var _NotifyTitle = document.title;
        
function flash_title() {
            
if (_IsFlash) {
                document.title 
= '[新通知]-' + _NotifyTitle;
                _IsFlash 
= false;
            } 
else {
                document.title 
= '[]-' + _NotifyTitle;
                _IsFlash 
= true;
            }
        }

 

 

 

posted @ 2008-08-13 10:33  chenjunbiao  阅读(271)  评论(0编辑  收藏  举报