Reputation: 429
I am using praeclarum sqlite-net library for xamarin c#, when I am using :
var item = sQLiteConnection.Table<MyClass>()
.Where(e => (e.Id == CurrentId) && (e.name == Currentname));
It gives exception: Member access failed to compile expression
CurrentId and Currentname both have a value. The table does exist with its columns.
MyClass is:
public class MyClass
{
[Ignore]
public List<ClassB> Bs{ get; set; }
public string BsAsJson { get; set; }
public string Datestamp { get; set; }
[PrimaryKey]
public string ClassId { get; set; }
public string SomeId { get; set; }
public string name { get; set; }
public MyClass ()
{ }
public MyClass (string datestamp, string id)
{
Bs= new List<ClassB>();
Datestamp = datestamp;
ClassId = id;
name= "Bagera";
SomeId= "SomeValue";
}
}
Upvotes: 0
Views: 1385
Reputation: 429
Passing CurrentId as parameter fixed my problem.
Before, I used the function like this where Current Id = StaticClassA.MyStaticList[StaticIndex].Id
public list<MyClass> GettAll()
{
var item = sQLiteConnection.Table<MyClass>()
.Where(e => (e.Id == CurrentId) && (e.name == Currentname));
return item.ToList();
}
The code before will throw => exception: Member access failed to compile expression.
But, when I pass CurrentId as parameter it works fine:
public list<MyClass> GettAll(string id)
{
var item = sQLiteConnection.Table<MyClass>()
.Where(e => (e.Id == id) && (e.name == Currentname));
return item.ToList();
}
I still don't know what is the difference !
Hope this will help someone.
Upvotes: 1