我首先使用Entity Framework 4.4代码(工厂模式)从现有Oracle视图中获取数据.这是我的实体类:
class Data
{
[Required]
[StringLength(50)]
public String EmailAddress { get; set; }
[Required]
[StringLength(200)]
public String FundName { get; set; }
[Required]
[DecimalPrecision(AllowedPrecision=15,AllowedScale=0)]
public Decimal FundCode { get; set; }
[StringLength(3)]
public String BankCode { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的Map类
class DataMap : EntityTypeConfiguration<Data>
{
public DataMap() : base()
{
// Properties
Property(t => t.EmailAddress).HasColumnType("varchar2");
Property(t => t.FundName;
Property(t => t.FundCode
Property(t => t.BankCode).HasColumnType("varchar2");
// Table
ToTable("VIEW_FD_EMAIL");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的上下文类
class OracleContext : DbContext
{
static OracleDataEntities() …Run Code Online (Sandbox Code Playgroud)