I have an issue with next scheme, I attached it.I want to query from my database with only one object with "Manufacturer
" class. Like:
var res = new XPQuery<Manufacturer>(session);
And then query all info that are related to my condition in LINQ.
I have tried XPLiteObject, XPObject, Association attribute, NoForeignKey Attribute, XPOCollection
and a lot of stuff but nothing didn't help me.
I have tried a lot of approaches and every time I have new exception like: SelectMany - method is not supported. Can't set foreign key in table. Duplicate primary key.
My question is: how to describe classes for normal extraction data from db?
UPD: My solution now is: to use .ToList() at every object and then use linq-query for join data and make needed query.
var manufacturer = new XPQuery<Manufacturer>(session).ToList();
var cars = new XPQuery<Car>(session).ToList();
var countries = new XPQuery<Country>(session).ToList();
var result = from m in manufacturer ....
So, I have found a solution to my question. I downloaded DevExpress that can add templates for visual studio. Then I select Add new item to my project named "DevExpress ORM DataModel Wizard". This wizard can create persistent objects for existing database. After that I can query database with next syntax:
var manufacturer = new XPQuery<Manufacturer>(session).Select(x => x....)...;
But if you want to use .SelectMany() in your LINQ query you should use .ToList() and then use .SelectMany(). I faced with a lot of issues when I have tried to join or perform some other LINQ related operations. Well, if you got some errors, firstly after .Select() try .ToList() and then perform your operation.