Hi I have this interface:
public interface X {
int Id { get; set; }
int Number { get; set; }
}
And I want an entity generated by Entity Framework that have this properties to implement this interface. How I do it? I tried to do a partial class but I get a compile error that force me to implement the properties in interface as I show below.
public partial class A : X {
int Id { get; set; }
int Number { get; set; }
}
This is the class generated by Entity Framework:
//------------------------------------------------------------------------------
// <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; }
}
}
I have these current files:
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; }
}
}
2.
namespace ConfApp.model {
public interface IInstituicao {
int Id { get; set; }
String Nome { get; set; }
String Morada { get; set; }
String Pais { get; set; }
}
}
3.
namespace ConfApp.model {
public partial class INSTITUICAO: IInstituicao {
}
}
<TEntity> GetId(this Entity entity){}maybe?