You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static void Main(string[] args)
{
Occupation occupation = new Occupation()
{
OccupationName = "Oc"
};
Names names = new Names()
{
Name = "a",
LastName = "b",
Occupation = occupation
};
List<Names> nameslist = new List<Names>();
nameslist.Add(names);
MyMainClass myMainClass = new MyMainClass()
{
ID = 1,
Names = nameslist
};
using (var db = new LiteDatabase(@"MyData.db"))
{
var col = db.GetCollection<MyMainClass>(nameof(MyMainClass));
col.EnsureIndex(x => x.ID, true);
col.Insert(myMainClass);
var r = col
.Include(x => x.Names)
.FindAll()
.FirstOrDefault();
Console.WriteLine(r);
}
}
public class MyMainClass
{
public int ID { get; set; }
public List<Names> Names { get; set; }
}
public class Names
{
public string Name { get; set; }
public string LastName { get; set; }
public Occupation Occupation { get; set; }
}
public class Occupation
{
public string OccupationName { get; set; }
}
Running this only loading only Names but Occupation is null.
I also tried on this way
var r = col .Include(x => x.Names) .Include(x => x.Names.Select(n => n.Occupation)) .FindAll() .FirstOrDefault();
The text was updated successfully, but these errors were encountered:
Here is my example:
Running this only loading only Names but Occupation is null.
I also tried on this way
var r = col .Include(x => x.Names) .Include(x => x.Names.Select(n => n.Occupation)) .FindAll() .FirstOrDefault();
The text was updated successfully, but these errors were encountered: