Ryan
Ryan

Reputation: 3982

How do I get an Object from the Primary Key

In C# and Sqllite I am using this to retrieve an object from it's primary key (the object property Id is marked [PrimaryKey])

return Connection.Table<MyObj>().Where(o => o.Id.Equals(idToFind)).First();

Seems a bit verbose. Is there an easier way to retrieve the object?

Upvotes: 1

Views: 192

Answers (1)

Salah Akbari
Salah Akbari

Reputation: 39976

You can use the Find method:

Connection.Table<MyObj>().Find(idToFind);

Upvotes: 2

Related Questions