58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using Dapper;
|
|
using Dapper.Contrib.Extensions;
|
|
using System.Data.SqlClient;
|
|
using static DbTableClass;
|
|
public class mediaItemDetail : optionItem
|
|
{
|
|
DbConn dbConn = new DbConn();
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
public List<mediaItem> mediaSpecList = new List<mediaItem>();
|
|
|
|
private optionItem _optionItem;
|
|
public mediaItemDetail() {
|
|
_optionItem = new optionItem();
|
|
}
|
|
|
|
public mediaItemDetail(string _optionItem_uid) {
|
|
|
|
_optionItem = conn.QueryFirstOrDefault<optionItem>("select * from optionItem where optionItem_uid = @optionItem_uid", new { optionItem_uid = _optionItem_uid });
|
|
|
|
if (_optionItem != null)
|
|
{
|
|
Type dataType = _optionItem.GetType();
|
|
|
|
foreach (var prop in dataType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = dataType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(_optionItem, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
mediaSpecList = conn.Query<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid order by mediaItem_order", new { optionItem_uid = _optionItem_uid}).ToList();
|
|
}
|
|
else {
|
|
_optionItem = new optionItem();
|
|
}
|
|
}
|
|
|
|
public mediaItemDetail(optionItem _obj) {
|
|
_optionItem = _obj;
|
|
|
|
Type dataType = _optionItem.GetType();
|
|
|
|
foreach (var prop in dataType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = dataType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(_optionItem, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
mediaSpecList = conn.Query<mediaItem>("select * from mediaItem where mediaItem_ishide = 'N' and optionItem_uid = @optionItem_uid order by mediaItem_order", new { optionItem_uid = _optionItem.optionItem_uid }).ToList();
|
|
}
|
|
}
|