publicclassProgram{[Document(Prefixes =new[]{"Employee"})]publicclassEmployee{[RedisIdField]publicstring Id{get;set;}publicstring Name {get;set;}publicint Age {get;set;}publicdouble Sales {get;set;}publicstring Department {get;set;}}staticasyncTaskMain(string[] args){var provider =newRedisConnectionProvider("redis://localhost:6379");var connection = provider.Connection;var employees = provider.RedisCollection<Employee>();var employee1 =newEmployee{Name="Bob", Age=32, Sales =100000, Department="Partner Sales"};var employee2 =newEmployee{Name="Alice", Age=45, Sales =200000, Department="EMEA Sales"};var idp1 =await connection.SetAsync(employee1);var idp2 =await employees.InsertAsync(employee2);var reconstitutedE1 =await connection.GetAsync<Employee>(idp1);var reconstitutedE2 =await employees.FindByIdAsync(idp2); Console.WriteLine($"First Employee's name is {reconstitutedE1.Name}, they are {reconstitutedE1.Age} years old, "+$"they work in the {reconstitutedE1.Department} department and have sold {reconstitutedE1.Sales}, "+$"their ID is: {reconstitutedE1.Id}"); Console.WriteLine($"Second Employee's name is {reconstitutedE2.Name}, they are {reconstitutedE2.Age} years old, "+$"they work in the {reconstitutedE2.Department} department and have sold {reconstitutedE2.Sales}, "+$"their ID is: {reconstitutedE2.Id}");}}
First Employee's name is Bob, they are 32 years old, they work in the Partner Sales department and have sold 100000, their ID is: 01FHDFE115DKRWZW0XNF17V2RK
Second Employee's name is Alice, they are 45 years old, they work in the EMEA Sales department and have sold 200000, their ID is: 01FHDFE11T23K6FCJQNHVEF92F