34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using Dapper;
|
|
using Dapper.Contrib.Extensions;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System.Data.SqlClient;
|
|
using static DbTableClass;
|
|
|
|
public class newsDetial: news
|
|
{
|
|
DbConn dbConn = new DbConn();
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
public List<tag> tags = new List<tag>();
|
|
public List<photo> photos = new List<photo>();
|
|
public newsDetial() {
|
|
|
|
}
|
|
|
|
public newsDetial(news obj) {
|
|
Type newsType = obj.GetType();
|
|
|
|
foreach (var prop in newsType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = newsType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(obj, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
tags = conn.Query<tag>("select * from tag where news_uid = @news_uid", new { news_uid = this.news_uid }).ToList();
|
|
photos = conn.Query<photo>("select * from photo where news_uid = @news_uid", new { news_uid = this.news_uid }).ToList();
|
|
}
|
|
}
|