你好我有这个界面:
public interface X {
int Id { get; set; }
int Number { get; set; }
}
我想要一个由实体框架生成的具有此属性的实体来实现此接口。我怎么做?我试图做一个部分类,但我得到一个编译错误,迫使我在接口中实现属性,如下所示。
public partial class A : X {
int Id { get; set; }
int Number { get; set; }
}
这是实体框架生成的类:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace App
{
using System;
using System.Collections.Generic;
public partial class A
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public A()
{
}
public int Id { get; set; }
public int Number { get; set; }
}
}
我有这些当前文件:
1.
namespace ConfApp.model
{
using System;
using System.Collections.Generic;
public partial class INSTITUICAO
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public INSTITUICAO()
{
this.UTILIZADOR = new HashSet<UTILIZADOR>();
}
public int Id { get; set; }
public string Nome { get; set; }
public string Morada { get; set; }
public string Pais { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<UTILIZADOR> UTILIZADOR { get; set; }
}
}
GCT1015
呼唤远方
相关分类