Smartkid's binary life

博客园 联系 订阅 管理
  5 Posts :: 1 Stories :: 7 Comments :: 0 Trackbacks

2008年6月29日 #

The unit test in Visual Studio has a bug:
AppDomain.CurrentDomain.BaseDirectory always returns the installtion directory of the visual studio 2008 instead of the 'Out' directory.

So if your code have to access data files deployed to the 'Out' directory using relative path, error occurs.

A workaround is:

        public static GetApplicationBaseDirectory {
            
if (AppDomain.CurrentDomain.FriendlyName.StartsWith("UnitTestAdapterDomain_")) {
                
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            }

                
return AppDomain.CurrentDomain.BaseDirectory;
        }


posted @ 2008-06-29 02:53 Smartkid 阅读(475) | 评论 (0)编辑

2007年6月6日 #

愚蠢的做法: http://weblogs.asp.net/nunitaddin/pages/microsoft-lawyers-chapter-3.aspx 明智的改变: http://www.theserverside.net/news/thread.tss?thread_id=45690&asrc=EM_NLN_1537240&uid=2449092
posted @ 2007-06-06 14:07 Smartkid 阅读(323) | 评论 (0)编辑

2007年5月13日 #

 

WITH Digits AS (
    
SELECT 0 as Number
    
UNION SELECT 1
    
UNION SELECT 2
    
UNION SELECT 3
    
UNION SELECT 4
    
UNION SELECT 5
    
UNION SELECT 6
    
UNION SELECT 7
    
UNION SELECT 8
    
UNION SELECT 9

SELECT
   (d5.
Number * 100000
    
+ (d4.Number * 10000
    
+ (d3.Number * 1000
    
+ (d2.Number * 100
    
+ (d1.Number * 10
    
+ d0.Number as Number
FROM
    Digits 
AS d0
    , Digits 
AS d1
    , Digits 
AS d2
    , Digits 
AS d3
    , Digits 
AS d4
    , Digits 
AS d5
在SQLServer 2005中,这个SQL返回一个包含1000000条记录的结果集,从0到999999。
这条语句利用了SQL2005的新功能:CTE (Common Table Expression)
如果当前的数据库是SQL 2000或其他不支持CTE的数据库,则可以将WITH部分的SQL定义为一个视图。

CREATE VIEW .[Digits] AS
SELECT 0 AS Number
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5
UNION SELECT 6
UNION SELECT 7
UNION SELECT 8
UNION SELECT 9;

CREATE VIEW [MillionNumbers] AS
SELECT
SELECT (d5.Number * 100000
    
+ (d4.Number * 10000
    
+ (d3.Number * 1000
    
+ (d2.Number * 100
    
+ (d1.Number * 10
    
+ d0.Numberas Number
FROM
    Digits 
AS d0
    , Digits 
AS d1
    , Digits 
AS d2
    , Digits 
AS d3
    , Digits 
AS d4
    , Digits 
AS d5;

 我们可以用这个方法来生成大批量的测试数据。如:
INSERT INTO MyTest (RecordId, RecordIndex)
SELECT newid(), Number FROM MillionNumbers

用此方法插入数据,要比利用循环快很多倍。

posted @ 2007-05-13 14:52 Smartkid 阅读(793) | 评论 (0)编辑

在PowerDesigner 的 SQLServer2005的PDM (Physical Data Model) 中创建SCHEMA的方法:
1)主菜单: Model/Users and Roles/Users
2)  创建一个User
3)  将次user的stereotype 设为schema.
是不是很隐晦啊~~~~

posted @ 2007-05-13 00:33 Smartkid 阅读(317) | 评论 (0)编辑

2007年2月22日 #

IBatisNetGen generates IBatisNet SQL mapping file and a group of CSharp classes from a database table.

Output for each database table
  • Entity, the C# class that represents a database record.
  • DaoIntf, the C# DAO interface contains a group of data manipulation methods, such as:
    • GetCount, gets the count of all records.
    • FindAll, loads all database records.
    • Find, loads a database record using primary key value(s).
    • FindByXXX, loads a group of records by the value of a column.
    • Delete, deletes a database record.
    • DeleteByXXX, deletes a group of records of by the value of a column.
    • Update, updates a database record.
  • DaoImpl, the C# DAO implementation class that implements the interface referred by DaoIntf.
  • SqlMap, the IBatis.NET SQL mapping file that contains SQL statements used in the DaoImpl above.

Download IBatisNetGen

posted @ 2007-02-22 19:35 Smartkid 阅读(3303) | 评论 (7)编辑