Skip to content

Attribute to specify the Key (ID) #320

@sact1909

Description

@sact1909

Create an attribute that allows the user to specify the Key property to use as ID when post a new object in case someone wants to use his datatype key structure as Guid, AutoEnum etc...

Example
Model Class

public class TodoItem
{
    [FirebaseKey]
    public Guid ID {get;set;}
    public string Title { get; set; }
}

await firebaseClient.Child("Todo").PostAsync(new TodoItem
{
    ID = Guid.NewGuid(),
    Title = "This is a Text"
});

Result in Firebase RealTiem Database

"Todo":{
    "621e7bf1-1d39-493f-a6b1-537afb5efa41":{
      "Title":"This is a Text"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions