SQL 语句如下
select (@i:=@i+1) as No,
T.VIDEO_POSTER_PATH TemplateCover,
T.PGM_NM TemplateName,
T.PGM_ID TemplateId,
(SELECT CODE_NM FROM MV_TCODEDTL WHERE CATEGORY_ID = 'PGMTY' AND CODE_VALUE = T.PGM_TYPE) TemplateType,
T.PGM_RATIO TemplateSize,
T.PGM_SCALING TemplateScale,
T.PNG_COUNT TemplatePhoto,
T.PGM_TIME TemplateTime,
T.PGM_PRICE TemplatePrice,
(SELECT CODE_ATTR FROM MV_TCODEDTL WHERE CATEGORY_ID = 'ITMTY' AND CODE_VALUE = T.ITM_TYPE) TemplateAmount
from mv_tpgm T
,(select @i:=0) as it
ENTITY 结构如下
[NotMapped]
public string No { get; set; }
public string TemplateId { get; set; }
public string TemplateCover { get; set; }
public string TemplateName { get; set; }
[NotMapped]
public string TemplateType { get; set; }
public string TemplateSize { get; set; }
public string TemplateScale { get; set; }
public int TemplatePhoto { get; set; }
public string TemplateTime { get; set; }
public string TemplatePrice { get; set; }
[NotMapped]
public string TemplateAmount { get; set; }
public string UseYn { get; set; }
[NotMapped]
public DateTime TemplateBuildTime { get; set; }
public string RegId { get; set; }
public DateTime? RegTime { get; set; }
public string ModId { get; set; }
public DateTime? ModTime { get; set; }
map 结构如下
this.HasKey(t => t.TemplateId);
this.Property(t => t.TemplateId).HasColumnName("PGM_ID");
this.Property(t => t.TemplateCover).HasColumnName("VIDEO_POSTER_PATH");
this.Property(t => t.TemplateName).HasColumnName("PGM_NM");
this.Property(t => t.TemplateSize).HasColumnName("PGM_RATIO");
this.Property(t => t.TemplateScale).HasColumnName("PGM_SCALING");
this.Property(t => t.TemplatePhoto).HasColumnName("PNG_COUNT");
this.Property(t => t.TemplateTime).HasColumnName("PGM_TIME");
this.Property(t => t.TemplatePrice).HasColumnName("PGM_PRICE");
this.Property(t => t.UseYn).HasColumnName("USE_YN");
//this.Property(t => t.TemplateAmount).HasColumnName("PAY_AMT_TIME");
this.Property(t => t.RegId).HasColumnName("REG_ID");
this.Property(t => t.RegTime).HasColumnName("REG_TM");
this.Property(t => t.ModId).HasColumnName("MOD_ID");
this.Property(t => t.ModTime).HasColumnName("MOD_TM");
//Map(t =>
//{
// t.Properties(p => new { p.TemplateId, p.TemplateCover, p.TemplateName, p.TemplateSize,p.TemplateScale, p.TemplatePhoto, p.TemplateTime, p.TemplatePrice });
// t.ToTable("mv_tpgm");
//});
//Map(t =>
//{
// t.Properties(p => new { p.TemplateType });
// t.ToTable("mv_tcodedtl");
//});
不知道怎么做映射了
这个应该做不了
没懂你映射2张表的目的是什么,这是同一个数据库的2张表吗
两种方法,1、sql写视图,2、AutoMapper.Mapper的mapto可以重构一下