Reputation: 1992
In LINQPad 5 with Linq-to-Sql DataContext
, if I dump out a table.
Users.Take( 5 ).Dump();
The results pane has properties in order they were defined in the .dbml
file, and thus in the order they were placed in the generated C# class.
In LINQPad 8 with EF Core DbContext
objects, if I dump out the same table, the properties are always dumped in alphabetical order vs the order of property declaration in the scaffolded class.
Is there a way to make it dump based on order of declaration?
I saw post about Change order of dump properties which I could maybe implement, but would rather just get a default behavior of order properties appear in class.
Using reflection, if I do typeof( KAT.Camelot.DbContexts.Evolution.AWS.User ).GetProperties().Dump();
the order of the properties listed is in order of declaration.
Update: Screenshot of output and code.
Here is scaffolded class:
[Table("User")]
[Index("AuthID", "GroupKey", Name = "UniqueAuthID", IsUnique = true)]
[Index("Email", "GroupKey", Name = "UniqueEmail", IsUnique = true)]
public partial class User
{
[Key]
[Column("User_id")]
public int Key { get; set; }
/// <summary>
/// Foreign Key to Group
/// </summary>
[Column("User_Group_id")]
public int? GroupKey { get; set; }
[Column("User_Authenticate_id")]
[StringLength(100)]
[Unicode(false)]
public string? AuthID { get; set; }
[Column("User_Register_id")]
[StringLength(255)]
[Unicode(false)]
public string? RegisterID { get; set; }
[Column("User_Profile", TypeName = "text")]
public string? Profile { get; set; }
[Column("User_Email")]
[StringLength(200)]
[Unicode(false)]
public string? Email { get; set; }
[Column("User_Pin")]
[StringLength(100)]
[Unicode(false)]
public string? Pin { get; set; }
[Column("User_Timeout", TypeName = "datetime")]
public DateTime? Timeout { get; set; }
[Column("Create_Date", TypeName = "datetime")]
public DateTime? CreateDate { get; set; }
[Column("Mod_Date", TypeName = "datetime")]
public DateTime? UpdateDate { get; set; }
/// <summary>
/// Date user last logged onto the system.
/// </summary>
[Column("User_LastOn", TypeName = "smalldatetime")]
public DateTime? LastOnDate { get; set; }
/// <summary>
/// Whether or not the user can log onto the system.
/// </summary>
[Column("User_Active")]
public bool? Active { get; set; }
[Column("userPasswordExpire", TypeName = "smalldatetime")]
public DateTime? PasswordExpire { get; set; }
[Column("uFailureCount")]
public int? FailureCount { get; set; }
[Column("userAdmin")]
public bool? Admin { get; set; }
/// <summary>
/// The 'AuthID' the admin will use to sign in with (if not same as real auth id - use when people are both participants and admins)
/// </summary>
[Column("uAdminAuthID")]
[StringLength(255)]
[Unicode(false)]
public string? AdminAuthID { get; set; }
[Column("User_Token")]
[StringLength(50)]
[Unicode(false)]
public string? Token { get; set; }
/// <summary>
/// If this matches cookie in users browser then they can autologon.
/// </summary>
[Column("User_AutoLogon")]
[StringLength(50)]
[Unicode(false)]
public string? AutoLogon { get; set; }
[Column("uStayLoggedIn")]
public bool? StayLoggedIn { get; set; }
[Column("uProcessed")]
public bool? Processed { get; set; }
[Column("uIVRPin")]
[StringLength(20)]
[Unicode(false)]
public string? IVRPin { get; set; }
[Column("uEmailReset")]
[StringLength(200)]
[Unicode(false)]
public string? EmailReset { get; set; }
[Column("uSingleSignOnID")]
[StringLength(100)]
[Unicode(false)]
public string? SingleSignOnID { get; set; }
[Column("uAuthenticatorKey")]
[StringLength(15)]
[Unicode(false)]
public string? AuthenticatorKey { get; set; }
[Column("uMobileNumber")]
[StringLength(15)]
[Unicode(false)]
public string? MobileNumber { get; set; }
[Column("uAuthenticatorGrace")]
public int? AuthenticatorGrace { get; set; }
[ForeignKey("GroupKey")]
[InverseProperty("Users")]
public virtual Group? Group { get; set; }
[InverseProperty("User")]
public virtual ICollection<Preference> Preferences { get; set; } = new List<Preference>();
}
Upvotes: 1
Views: 42