Net Cheat Sheet VF
Net Cheat Sheet VF
primary key :
[Key]
multiligne
[DataType(DataType.MultilineText)]
OneToMany config :
Using Annotation
Entity1: Entity2:
prop… public virtual IList<Entity1> ent1{ get; set; }
public (Entity2 primary key Type ) ent2FK
prop…
[ForeignKey("ent2FK")]
public virtual Entity2 ent2 { get; set; }
Using fluent Api
2 ways :
1/ configuration file => apply config
2/ context
builder.hasmany(t=>t.entx)
.withmany(p=>p.enty)
.usingentity(p=>p.totable(“ name”))
complex type
Using Annotation
[Owned]
Entity3 Entity4
string prop1 Entity3 prop
string prop2
Heritage configuration
TPH:Using discriminator
modelbuilder.Entity<Entity1>().hasdesciminator<type )>(“name”)
.hasvalue<>(entity1)(1)
.hasvalue<>(entity2)(2)
.hasvalue<>(entity3)(3)
TPT : table per type
modelbuilder.Entity<Entity2>()totable(“ent2”)
modelbuilder.Entity<Entity>()totable(“ent3”)
table porteuse
builder.haskey(r=>new{
r.ent1FK,
r.ent2FK
r.date}
design patterns
Interface
public interface IServiceEntity :IService<Entity>
service
public class ServiceEntity : Service<Entity>, IServiceEntiy