欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

c#中xml文档注释编译dll引用到其它项目示例

程序员文章站 2023-12-21 00:02:28
复制代码 代码如下:<#@ 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; }
       <#}#>       
    }           
    <#}#>              
}

上一篇:

下一篇: