Skip to content

Commit

Permalink
Add the collection string property to customer in alternatekey sample
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhg committed Mar 8, 2022
1 parent 41467d4 commit 211f41d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public IActionResult Get(int key)
return Ok(c);
}

[HttpPost]
[EnableQuery]
public IActionResult Post([FromBody]Customer c)
{
return Ok(c);
}

// Alternate key: SSN
[HttpGet("odata/Customers(SSN={ssn})")]
public IActionResult GetCustomerBySSN(string ssn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ static AlternateKeyRepositoryInMemory()
{
Id = e,
Name = names[e - 1],
SSN = "SSN-" + e + "-" + (100 + e)
SSN = "SSN-" + e + "-" + (100 + e),
Titles = new string[] { "abc", null, "efg" }
}).ToList();

// Orders
Expand Down
2 changes: 2 additions & 0 deletions sample/ODataAlternateKeySample/Models/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public class Customer
public string Name { get; set; }

public string SSN { get; set; }

public string[] Titles { get; set; }
}
}

0 comments on commit 211f41d

Please sign in to comment.