-
Notifications
You must be signed in to change notification settings - Fork 79
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
[RedisIdField] issue when using type different then string, GUID or Ulid #286
Comments
@Zlejsi - can you share some code that reproduces this error? Thanks, |
@slorello89 - here is TestRepo with error |
@Zlejsi , try changing the Id from int to String! GenerateId is a string and your Id is int.. |
@zulander1 put their finger on it, the IdGenerationStratagey API is an advanced use-case but it's intended to provide a string id to use in the key. |
Ok. I understand that it is advanced use case, but as i wrote before, you provide a way to set RedisIdField not only as string, but as different types also. I only paste my way to fix the issue to use field with integer value in it. |
@slorello89 maybe we should do a generic IIdGenerationStrategy and return as T, this should resolve this issue |
Fixed type casting issue for redis#286
Should be fixed by #302 |
When using different type then string, GUID or Ulid at [RedisIdField] attribute, program throw an exception.
C# System.ArgumentException: 'Object of type 'System.String' cannot be converted to type 'System.Int32'.'
As example i used System.Int32 as type.
Problem is at converting Id generated by GenerateId() method.
class RedisObjectHandler.cs
FIXED by using
propertyInfo.SetValue(obj, Convert.ChangeType(str,info.PropertyType),null);
The text was updated successfully, but these errors were encountered: