Mercurial > pub > bltoolkit
diff UnitTests/CS/DataAccess/TestQueryAttribute.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UnitTests/CS/DataAccess/TestQueryAttribute.cs Thu Mar 27 21:46:09 2014 +0400 @@ -0,0 +1,63 @@ +using System; + +using BLToolkit.Data.DataProvider; +using BLToolkit.DataAccess; + +namespace DataAccess +{ + public class TestQueryAttribute : SqlQueryAttribute + { + public TestQueryAttribute() + { + IsDynamic = true; + } + + private string _accessText; + public string AccessText + { + get { return _accessText; } + set { _accessText = value; } + } + + private string _oracleText; + public string OracleText + { + get { return _oracleText; } + set { _oracleText = value; } + } + + private string _fbText; + public string FbText + { + get { return _fbText; } + set { _fbText = value; } + } + + private string _SQLiteText; + public string SQLiteText + { + get { return _SQLiteText; } + set { _SQLiteText = value; } + } + + public override string GetSqlText(DataAccessor accessor, BLToolkit.Data.DbManager dbManager) + { + switch (dbManager.DataProvider.Name) + { + case ProviderName.MsSql : + case ProviderName.SqlCe : return SqlText; + + case ProviderName.Access : return AccessText ?? SqlText; + + case "Oracle": + case ProviderName.Oracle : return OracleText ?? SqlText; + + case ProviderName.Firebird: return FbText ?? SqlText; + + case ProviderName.SQLite : return SQLiteText ?? SqlText; + } + + throw new ApplicationException(string.Format("Unknown data provider '{0}'", dbManager.DataProvider.Name)); + } + } +}