Skip to content

NullReferenceException: When "Name" optionally not supplied to [Column] Attribute #20

@z0nekill

Description

@z0nekill

Hello! I've been experimenting with your library in .NET 8 and I really like it - I'll cut straight to the chase:

return attrAccessor[MappingAttributeNames.LinqToDbFieldMapAttributePropertyName].ToString();

Has a minor bug where it presumes that the Attribute name is required, it is not. When calling ToString on the Dictionary indexer throws the NullReferenceException

Example:

[Table("AppHit")]
public partial class AppHit
{
    [Key]
    [Column("HitID")]
    public Guid HitId { get; set; }

    [Column("SessionID")]
    public Guid SessionId { get; set; }

    // Issue => Name Optionally set
    [Column(TypeName = "datetime")]
    public DateTime Timestamp { get; set; }
}

In cases such as these I believe it would be acceptable to fall back to propInfo.Name.

Unfortunately, .NET developers using Database First projects cannot force the Name to be required, as the above file is generated automatically.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions