0
這是ApplicationUser:過濾DbSet中的EntityFramework CodeFirst
public class ApplicationUser : IdentityUser<long>
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public UserTypes Type { get; set; }
public string FullName { get { return $"{Firstname ?? ""} {Lastname ?? ""}".Trim(); } }
}
我們有3個不同的UserTypes(供應商,支持者,NormalUser (這是ApplicationUser))
public class Provider : ApplicationUser{
// Provider related virtual Icollections
}
public class Supporter : ApplicationUser{
// Supporter related virtual Icollections
}
在
現在ApplicationDbContext
我想在應用程序旁邊有這些DbSet
s:
public virtual DbSet<Provider> Providers{get;set;}
public virtual DbSet<Supporter> Supporters{get;set;}
哪個DbSet<Provider>
應該返回ApplicationUsers
他們UserTypes
等於2(例如)
什麼UserTypes的屬性? –
@ H.Herzl以及它是一個枚舉'{Normal = 1,Provider = 2,Supporter = 3}' –
你試過這個嗎? var query = dbContext.Providers.Where(item => item.Type == UserTypes.Provider).ToList(); –