C
C#2mo ago
Yarden

✅ I need help with explanation of given entity attributes

Updated the post I've got recommended to add 3 attributes to my Entity:
[Timestamp]
public byte[] RowVersion { get; set; }
public DateTime CreatedAtUtc { get; set; }
public DateTime ModifiedAtUtc { get; set; }
[Timestamp]
public byte[] RowVersion { get; set; }
public DateTime CreatedAtUtc { get; set; }
public DateTime ModifiedAtUtc { get; set; }
cs This is my current Entity class:
[Index(nameof(UserName), IsUnique = true)]
[Index(nameof(Email), IsUnique = true)]
public class UserEntity
{

[Timestamp]
public byte[] RowVersion { get; set; }
public DateTime CreatedAtUtc { get; set; }
public DateTime ModifiedAtUtc { get; set; }

[Key] public int Id { get; set; }

[Required, MaxLength(30)]
[RegularExpression ("^[a-zA-Z0-9]+$")] //User name should not contain special characters
public string UserName { get; set; } = default!;

[Required, MaxLength(254), EmailAddress]
public string Email { get; set; } = default!;

... More attribut...
[Index(nameof(UserName), IsUnique = true)]
[Index(nameof(Email), IsUnique = true)]
public class UserEntity
{

[Timestamp]
public byte[] RowVersion { get; set; }
public DateTime CreatedAtUtc { get; set; }
public DateTime ModifiedAtUtc { get; set; }

[Key] public int Id { get; set; }

[Required, MaxLength(30)]
[RegularExpression ("^[a-zA-Z0-9]+$")] //User name should not contain special characters
public string UserName { get; set; } = default!;

[Required, MaxLength(254), EmailAddress]
public string Email { get; set; } = default!;

... More attribut...
cs What is the problem? I guess I understood the purpose of CreatedAtUtc and ModifiedAtUtc. But RowVersion I still don't understand. I don't understand what exactly the purpose and how I suppose to manage this.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?