如何在反射中排除外键类型?

我试图在遍历对象时排除外键。

我正在通过下面的代码遍历该实体,但是不确定如何排除外键。

private static void Map<TEntity>(TEntity entity)
    {
        foreach (PropertyInfo prop in entity.GetType().GetProperties())
        {
            //If statement to exclude for foreign keys
            Console.WriteLine(prop.Name);
        }
    }

这是生成的实体,

public partial class ShiftTimes
{
    public ShiftTimes()
    {
        #region Generated Constructor
        #endregion
    }

    #region Generated Properties
    public Guid Id { get; set; }

    public DateTime? DateData { get; set; }

    public int? YearNo { get; set; }

    public int? MonthNo { get; set; }

    public int? DayNo { get; set; }

    public int? StaffNo { get; set; }

    public string SecondName { get; set; }

    public string FirstName { get; set; }

    public DateTime? TimeDataOne { get; set; }

    public DateTime? TimeDataTwo { get; set; }

    public string Code { get; set; }

    public int? Terminal { get; set; }

    public string SubSection { get; set; }

    public string Shift { get; set; }

    public Guid? ShiftId { get; set; }

    public Guid? StaffMemberId { get; set; }

    #endregion

    #region Generated Relationships
    public virtual ShiftCount ShiftShiftCount { get; set; }

    public virtual StaffDetail StaffMemberStaffDetail { get; set; }

    #endregion

}

向正确方向的任何推动将不胜感激。

评论