Skip to content
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

LoadByKey Fails Because Key Is Object But IKeyIndex<T, K> Needs K of Key Type #10

Closed
mkrain opened this issue Apr 17, 2013 · 2 comments
Closed

Comments

@mkrain
Copy link

mkrain commented Apr 17, 2013

Version 1.1.3.0:

public T LoadByKey < T > (object key) where T : class
{
return Table < T > ().LoadByKey(key);
}
...
var result = KeyIndex as IKeyIndex < T, K >;

The cast attempts to use object as K when in fact the type of the index is expected. Example:

public class Record
{
public long Id {get;set;}
}

Database.LoadByKey(7), causes an exception to be thrown:

{System.ArgumentException: Primary Index Object mismatch (Int64 expected)
at Lex.Db.DbTable1.GetPrimaryIndex [ K ] () at Lex.Db.DbTable1.LoadByKey [ K ](K key)
at Lex.Db.DbInstance.LoadByKey [ T ](Object key)
...

@demigor
Copy link
Owner

demigor commented Apr 17, 2013

Definitely my bad...

@juzzbott
Copy link

I am experiencing this behavior, with the example above, however using an int32 Id type. I'm currently using the 1.1.3.0 sources in a WP8 application from NuGet. Was this issue fixed at all?

demigor added a commit that referenced this issue Oct 7, 2013
Github issues #10
LoadByKey/LoadByKeys/DeleteByKey/DeleteByKeys overloads with untyped key
Github issue #11 fixed
Support for ObservableCollection<T>
@demigor demigor closed this as completed Oct 21, 2013
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

No branches or pull requests

3 participants