0

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? TableScheme

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 ....
Stanislav Balia
  • 385
  • 1
  • 12
  • I think you want to "Include" your referenced properties, right? Meaning having a "drilldown" from 1 object to others? – Dimitri Apr 08 '19 at 08:41
  • 1
    @Dimitri, yes, you are right. I added my solution into question, you can look at it. – Stanislav Balia Apr 08 '19 at 08:45
  • I have no experience at all with DevExpress but have a look at this=> https://documentation.devexpress.com/eXpressAppFramework/112681/Task-Based-Help/Filtering/How-to-Implement-Cascading-Filtering-for-Lookup-List-Views OR https://documentation.devexpress.com/eXpressAppFramework/113637/Getting-Started/Comprehensive-Tutorial-MainDemo-Application/Business-Model-Design/Business-Model-Design-with-Entity-Framework/Implement-Dependent-Reference-Properties-EF and see if that can help you. – Dimitri Apr 08 '19 at 08:52

1 Answers1

0

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.

Stanislav Balia
  • 385
  • 1
  • 12