c#中xml文档注释编译dll引用到其它项目示例
程序员文章站
2024-02-25 10:07:22
复制代码 代码如下:<#@ template debug="true" hostspecific="true" language="c#" #><#@ a...
复制代码 代码如下:
<#@ template debug="true" hostspecific="true" language="c#" #><#@ assembly name="system.core" #>
<#@ assembly name="system.data" #>
<#@ assembly name="system.xml" #>
<#@ import namespace="system.collections.generic" #>
<#@ import namespace="system.data" #>
<#@ import namespace="system.data.sqlclient" #>
<#@ import namespace="system.linq" #>
<#@ import namespace="system.text" #>
<#@ import namespace="system.collections.generic" #>
<#@ output extension=".cs" #>
using system;
using dotnet.framework.dataaccess.attribute;
using system.data;
namespace myproject.entities
{
<#
string connectionstring = "data source=localhost;initial catalog=ednframework;user id=sa;pwd=as";
sqlconnection conn = new sqlconnection(connectionstring);
conn.open();
system.data.datatable schema = conn.getschema("tables");
string selectquery = "select * from @tablename";
sqlcommand command = new sqlcommand(selectquery,conn);
sqldataadapter ad = new sqldataadapter(command);
system.data.dataset ds = new dataset();
foreach(system.data.datarow row in schema.rows)
{
#>
public class <#= row["table_name"].tostring()#>
{<#
ds.tables.clear();
command.commandtext = selectquery.replace("@tablename",row["table_name"].tostring());
ad.fillschema(ds, schematype.mapped, row["table_name"].tostring());
foreach (datacolumn dc in ds.tables[0].columns)
{#>
[datamapping("<#= dc.columnname #>")]
public <#= dc.datatype.name #> <#= dc.columnname #> { get; set; }
<#}#>
}
<#}#>
}
上一篇: c#操作ftp类分享