SQLite4Unity3d
SQLite4Unity3d copied to clipboard
Query
public IEnumerable<Person> GetPersonsNamedRoberto(){ return _connection.Table<Person>().Where(x => x.IName == "Roberto"); }
how to implement "Select IName from Person" this query on return line
Hi,
I have similar issue, when i use public IEnumerable<Person> GetPersonsNamedRoberto(){ return _connection.Table<Person>().Where(x => x.IName == "Roberto"); }
Unity return me a SQLite4Unity3d.TableQuery
1[Person]`
If you can help me?
The TableQuery class have Select method that apparently using to filter result like in SQL SELECT. But this method not working as intended.
_connection.Table<Person>()
.Where(x => x.IName == "Roberto")
.Select(person => person.IName )
.ToList();
That code should be return List
What working for me is get the list, then select it using linq:
using System.Linq;
List<string> names = _connection.Table<Person>()
.Where(x => x.IName == "Roberto")
.ToList()
.Select(person => person.IName )
.ToList();
That code will return List string of IName. I don't really like it because it's multiple ToList() :(