This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am thinking of switching from Linq to SQL to LightSpeed. I have a complex querying requirement. How does querying with Joins work in LightSpeed. I find it a bit slow in Linq to SQL. I have 5 objects. Jobs have Extras that have Drawings that have Assemblies that have Parts that have a PartID for the quantity of each part each part. I would like to set a filter on the Assemblies(for example) and then update my GUI(querying) to show only the Drawings, Extras and Jobs that Contain the Assemblies and only show the Parts per each assemblie. If I havent confused you too much is this something ligthspeed can handle with out a slow down in quering? |
|
|
Hi MiddleTommy, LightSpeed has an eager loading feature that allows you to pull back multiple levels of an object graph in a single query. For example, return a Customer, that Customer's Orders and the OrderLines for those Orders. Additionally, LightSpeed does not use outer-join fetching which means that no redundant data is returned. I would recommend spiking out a small prototype and playing around with the various query tuning options. You can examine the generated SQL by enabling logging on the LightSpeedContext object. Cheers, Andrew. |
|
|
well My first simple attempt failed with an error var q = from t in whip.Query<Job>()
AND var q = from t in whip.Query<Job>() The method or operation is not implemented. |
|
|
One of the current limitations of our LINQ implementation is that aggregate operators such as Sum(), Any() and Count() are supported only on queries as a whole (e.g. q.Count()), not within them. Sorry. |
|
|
Next I try this var q = from t in whip.Query<Job>() and get: Unexpected expression type while resolving subexpression So I tried var q = from t in whip.Query<Job>() And got the same result
So next I searched for another sample Linq to Sql subquery online and patched it into my Linq to LightSpeed to test it out var q = from t in whip.Query<Extra>() Unable to cast object of type 'System.Linq.Expressions.MemberExpression' to type 'System.Linq.Expressions.ConstantExpression'.
So I try the simplest relational query I can think of Job job = whip.Query<Job>().First(j => j.JobNo == "08-001"); //getting the Job works great then I try to use it Exception has been thrown by the target of an invocation; A problem I see with LightSpeed and Linq here is you dont have the ID of the parent Item stored in the Child Are these test scenarios possible with LightSpeed without the Linq? I always test the limits out of something new so I understand its limitations before I decide to use it.
|
|
|
Generally LightSpeed has limited support for queries that traverse multiple tables. Most of your queries want to join across the Job and Extra tables, and there is limited support for that. The LightSpeed native API does support traversal to fields, e.g. Find<Job>(Entity.Attribute("Extras.Extra") == "X1"); in currently nightlies you can do this in LINQ via SelectMany (see http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=1258). In your final example, the Where clause compares two entities; we would recast this as: var q = from t in whip.Query<Extra>() where t.JobId == job.Id select t; For one-to-many associations, you can get the ID of the parent as XxxId. For example, if a Car has a Wheels collection, then a Wheel would have a Car and a CarId. (These properties are automatically created by the designer from the association; if you hand-code your entity classes then you need to provide them.) I would also reiterate our earlier note that aggregate operators such as Any() can currently be used only on queries as a whole, not within where clauses as in your first couple of examples. |
|
|
Is it likely that LightSpeed will support multiple-table-traversing queries in the future, or is that just a fundamental limitation of the technology? LightSpeed currently supports a very finite subset of LINQ, which we had to discover the hard way. It would be nice if the constructs that are supported were documented more explicitly. |
|
|
It is likely that LightSpeed will support multiple-table-traversing queries in the future, but we do not have a specific schedule for this. We prioritise based on customer feedback and we are aware that quite a few people are asking for this. Thanks for your feedback on the documentation: we'll try to improve this area. I've logged a bug for it. |
|
|
Is there any progress on this feature request?
It's hard do develop anything using queries with multiple tables involved.
I have a query that is rather simple, but I get unsupported SelectMany operator:
public IQueryable GetInstrumenti()
{
InstrumentarijUnitOfWork unit = DatabaseController.GetInstance().CreateUnitOfWork();
var result = from i in unit.Instruments
from k in unit.Korisniks
where i.KorisnikId == k.Id
orderby k.Prezime, k.Ime
select i;
return result;
}
|
|
|
Hi milivojm :) You will be happy to know we are working through this as part of LightSpeed 3 which we are working towards a mid year release for. We are going to pop up a quick blog post about this today if you are are interested :)
Jeremy |
|