mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
SqlRemark
This commit is contained in:
parent
c5f53a33fd
commit
76c87d796f
@ -17,8 +17,9 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
// /***Unit Test***/
|
// /***Unit Test***/
|
||||||
|
new SqlRemark(2).Init();
|
||||||
new Select(1).Init();
|
new Select(1).Init();
|
||||||
new Field(1).Init();
|
new Field(1).Init();
|
||||||
new Where(1).Init();
|
new Where(1).Init();
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
<Compile Include="UnitTest\DataTest.cs" />
|
<Compile Include="UnitTest\DataTest.cs" />
|
||||||
<Compile Include="UnitTest\Delete.cs" />
|
<Compile Include="UnitTest\Delete.cs" />
|
||||||
<Compile Include="UnitTest\EnumTest.cs" />
|
<Compile Include="UnitTest\EnumTest.cs" />
|
||||||
|
<Compile Include="UnitTest\SqlRemark.cs" />
|
||||||
<Compile Include="UnitTest\UnitTestBase.cs" />
|
<Compile Include="UnitTest\UnitTestBase.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
||||||
<Compile Include="UnitTest\Insert.cs" />
|
<Compile Include="UnitTest\Insert.cs" />
|
||||||
|
45
Src/Asp.Net/SqlServerTest/UnitTest/SqlRemark.cs
Normal file
45
Src/Asp.Net/SqlServerTest/UnitTest/SqlRemark.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest.UnitTest
|
||||||
|
{
|
||||||
|
public class SqlRemark : UnitTestBase
|
||||||
|
{
|
||||||
|
private SqlRemark() { }
|
||||||
|
public SqlRemark(int eachCount)
|
||||||
|
{
|
||||||
|
this.Count = eachCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
var db = GetInstance();
|
||||||
|
|
||||||
|
//column remak
|
||||||
|
if (db.DbMaintenance.IsAnyColumnRemark("id", "student"))
|
||||||
|
{
|
||||||
|
db.DbMaintenance.DeleteColumnRemark("id", "student");
|
||||||
|
base.Check(false.ToString(), null, db.DbMaintenance.IsAnyColumnRemark("id", "student").ToString(), null, "SqlRemark error");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db.DbMaintenance.AddColumnRemark("id", "student","hhXX");
|
||||||
|
base.Check(true.ToString(), null, db.DbMaintenance.IsAnyColumnRemark("id", "student").ToString(), null, "SqlRemark error");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//table remak
|
||||||
|
if (db.DbMaintenance.IsAnyTableRemark("student"))
|
||||||
|
{
|
||||||
|
db.DbMaintenance.DeleteTableRemark("student");
|
||||||
|
base.Check(false.ToString(), null, db.DbMaintenance.IsAnyTableRemark("student").ToString(), null, "SqlRemark error");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
db.DbMaintenance.AddTableRemark("student", "hhXX");
|
||||||
|
base.Check(true.ToString(), null, db.DbMaintenance.IsAnyTableRemark("student").ToString(), null, "SqlRemark error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -223,26 +223,26 @@ namespace SqlSugar
|
|||||||
public virtual bool IsAnyColumnRemark(string columnName, string tableName)
|
public virtual bool IsAnyColumnRemark(string columnName, string tableName)
|
||||||
{
|
{
|
||||||
string sql = string.Format(this.IsAnyColumnRemarkSql, columnName, tableName);
|
string sql = string.Format(this.IsAnyColumnRemarkSql, columnName, tableName);
|
||||||
|
var dt=this.Context.Ado.GetDataTable(sql);
|
||||||
|
return dt.Rows!=null&&dt.Rows.Count>0;
|
||||||
|
}
|
||||||
|
public virtual bool AddTableRemark(string tableName, string description)
|
||||||
|
{
|
||||||
|
string sql = string.Format(this.AddTableRemarkSql, tableName, description);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool AddTableRemark(string columnName, string tableName, string description)
|
public virtual bool DeleteTableRemark(string tableName)
|
||||||
{
|
{
|
||||||
string sql = string.Format(this.AddTableRemarkSql, columnName, tableName, description);
|
string sql = string.Format(this.DeleteTableRemarkSql,tableName);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
this.Context.Ado.ExecuteCommand(sql);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public virtual bool DeleteTableRemark(string columnName, string tableName)
|
public virtual bool IsAnyTableRemark(string tableName)
|
||||||
{
|
{
|
||||||
string sql = string.Format(this.DeleteTableRemarkSql, columnName, tableName);
|
string sql = string.Format(this.IsAnyTableRemarkSql, tableName);
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
var dt=this.Context.Ado.GetDataTable(sql);
|
||||||
return true;
|
return dt.Rows != null && dt.Rows.Count > 0;
|
||||||
}
|
|
||||||
public virtual bool IsAnyTableRemark(string columnName, string tableName)
|
|
||||||
{
|
|
||||||
string sql = string.Format(this.IsAnyTableRemarkSql, columnName, tableName);
|
|
||||||
this.Context.Ado.ExecuteCommand(sql);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ namespace SqlSugar
|
|||||||
bool AddColumnRemark(string columnName,string tableName,string description);
|
bool AddColumnRemark(string columnName,string tableName,string description);
|
||||||
bool DeleteColumnRemark(string columnName, string tableName);
|
bool DeleteColumnRemark(string columnName, string tableName);
|
||||||
bool IsAnyColumnRemark(string columnName, string tableName);
|
bool IsAnyColumnRemark(string columnName, string tableName);
|
||||||
bool AddTableRemark(string columnName, string tableName, string description);
|
bool AddTableRemark( string tableName, string description);
|
||||||
bool DeleteTableRemark(string columnName, string tableName);
|
bool DeleteTableRemark(string tableName);
|
||||||
bool IsAnyTableRemark(string columnName, string tableName);
|
bool IsAnyTableRemark(string tableName);
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return "EXECUTE sp_addextendedproperty N'MS_Description', '{2}', N'user', N'dbo', N'table', N'{1}', N'column', N'{0}'"; ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return "EXEC sp_dropextendedproperty 'MS_Description','user',dbo,'table','{1}','column',{0}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -222,16 +222,24 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return @"SELECT" +
|
||||||
|
" A.name AS table_name," +
|
||||||
|
" B.name AS column_name," +
|
||||||
|
" C.value AS column_description" +
|
||||||
|
" FROM sys.tables A" +
|
||||||
|
" LEFT JOIN sys.extended_properties C ON C.major_id = A.object_id" +
|
||||||
|
" LEFT JOIN sys.columns B ON B.object_id = A.object_id AND C.minor_id = B.column_id" +
|
||||||
|
" INNER JOIN sys.schemas SC ON SC.schema_id = A.schema_id AND SC.name = 'dbo'"+
|
||||||
|
" WHERE A.name = '{1}' and b.name = '{0}'";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string AddTableRemarkSql
|
protected override string AddTableRemarkSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return "EXECUTE sp_addextendedproperty N'MS_Description', '{1}', N'user', N'dbo', N'table', N'{0}', NULL, NULL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +247,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return "EXEC sp_dropextendedproperty 'MS_Description','user',dbo,'table','{0}' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -248,7 +256,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return @"SELECT C.class_desc
|
||||||
|
FROM sys.tables A
|
||||||
|
LEFT JOIN sys.extended_properties C ON C.major_id = A.object_id
|
||||||
|
INNER JOIN sys.schemas SC ON SC.schema_id=A.schema_id AND SC.name='dbo'
|
||||||
|
WHERE A.name = '{0}' AND minor_id=0";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user