如果我有一个带有集合的类,是否可以使该ICollection具有通用性并使用Linq,那么我可以动态添加表吗?
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ContosoUniversity.Models
{
public class Course
{
public int CourseID { get; set; }
public string Title { get; set; }
public int Credits { get; set; }
public ICollection<Enrollment> Enrollments { get; set; }
}
}
ICollection可以是Generic,类似于这个吗?
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ContosoUniversity.Models
{
public class Course
{
public int CourseID { get; set; }
public string Title { get; set; }
public int Credits { get; set; }
public TEntity T {get; set;}
public ICollection<TEntity> T { get; set; }
}
}
我在连接表中有很多可以作为TEntity的表,我会在Linq查询中命名