Skip to content

Set timestamp from dynamic table entity if required #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 2, 2020

Conversation

fabiomaistro
Copy link
Contributor

Now if the system detects that a Timestamp property has been added to the POCO object, it automatically maps it to the Timestamp property available within the DynamicTableEntity.

Copy link
Owner

@giometrix giometrix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your two unit tests, i notice in both cases your input is an Employee but your output is an EmployeeWithTimestamp (or EmployeeWithTimestampAsString). While a valid use case , in most situations I think programmers will use the same POCO class for both input and output.

If in these two examples we change the input object to EmployeeWithTimestamp (or WithTimestampAsString), the tests fail.

I think the fix for this is to change line 158 of EntityConvert to:
if (entity.Properties.ContainsKey(propertyInfo.Name) && propertyInfo.Name != nameof(DynamicTableEntity.Timestamp)) , but you may find a better solution.

I look forward to hearing back from you, and thank you for your contribution!

@fabiomaistro
Copy link
Contributor Author

fabiomaistro commented Mar 2, 2020

Hi Giovanni, thanks for your comment, I fixed the code as you suggested and also changed the unit tests accordingly.

Actually, in my case, the use case is quite different: to keep abstraction (and avoid inheriting from ITableEntity) I pass my TObject type to a generic function that is querying the table storage through a DynamicTableEntity, then I use this library to map the DynamicTableEntity to return a List<TObject>. And that's why I was testing the change in that way.
Probably you could think about adding some tests considering the scenario where the FromTableEntity is called against a new DynamicTableEntity created from scratch (and not through your ToTableEntity method).

Also, you might consider implementing the same feature I did for timestamp also for the ETag.

@fabiomaistro fabiomaistro requested a review from giometrix March 2, 2020 23:01
@giometrix
Copy link
Owner

Looks great, and I will take your advice for both suggestions (starting with ETag).

As an aside, you might want to check out (and contribute to maybe to 🤞) https://github.com/giometrix/TableStorage.Abstractions.POCO , which sounds like it might be a superset of your query function plus TableEntityConverters.

Either way, thanks!

@giometrix giometrix merged commit adec9b6 into giometrix:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants