Subsonic how do I filter a loaded collection? - subsonic

Currently I am using Subsonic 2.1 and .NET 2.1 and I have an issue where I am attempting to filter a pre-loaded collection with 300+ items. I am using the following to attempt to preform the filter:
orders = MasterOrders.Where("account", mbrAccount).Load();
The end results is setting orders equal to the entire MasterOrders collection and not the filtered results. Any suggestions?

If you're targeting Dotnet Framework 3.5 you can use a LINQ select-query. Then convert it to a List<MasterOrder>.

Related

Getting the list of SQL select columns from JOOQ parser

I need to get the list of columns in a select using the JOOQ SQL parser. In the example below it would return the list with two entries: 'sk' and 'aa'. Debugging the program I can see in the Query.select field the list of columns, but I cannot find in the Query class a method to retrieve them. How to get the list of columns?
The Query object model returned by the jOOQ parser API does as of jOOQ 3.12 not provide any corresponding accessors. This feature is however planned for the next minor release (3.13).
The following answer gives you an example how you might be able to use the existing VisitListener SPI to achieve your goal: https://stackoverflow.com/a/54006668/1732086.

How can I find alfresco empty foldres using Lucene Query

I want to retrieve the list of folders in a specific node whose list of childrens is empty using Lucene query.
I create this query:
+PATH:"/app:company_home/cm:contexts/cm:ctx_exploitation/cm:runs/cm:Run_322645//."+Children is empty.
but it does not give good results.
What is the right Lucene syntax to do this
There is no way to find empty folders using a Lucene query.
However, there are some java services and javascript APIs in alfresco
like 'FileFolderService' in Java and 'childByNamePath' in javascript,
using them you can write your logic and find empty folders.
You can find o bytes file using below lucene query.
TYPE:"cm:content" AND #cm:content.size:0

how to filter the child entities but get all with eager loading?

I have two tables in my database in a 1:N relation and I would like to do a left join query with eager loading.
My tables are:
Videos (IDVIdeo, Name... )
Versions (IDVersion, IDVideo, Name, Avaliable...)
Well, in a video I can have many versions (DVD, Blu-Ray... etc) and a version only can belong to a video.
I would like to get all the videos which I have at least one available version (perhaps some version are in possession of one friend).
I would like to get all the videos that have at least avaliable version, but of this videos I want all the versions, avaliable and not avaliable.
So the first step is to know all the videos that have at least ona avaliable version and the second step is to get all the videos and all their versions (avaliable and not avaliable).
I would like to that with raw sql but how it is not possible to use eager loading with raw sql, I would like to use linq.
I want to use eager loading to use only one query to the database and not many, and because I would like to populate the collection versions in the video entity with its versions.
Thanks.
The solution using LINQ is rather straight-forward and would be:
var videos = context.Videos
.Include(v => v.Versions)
.Where(v => v.Versions.Any(vers => vers.Available))
.ToList();
If you really prefer raw SQL for this you can extract the SQL from this LINQ query:
var sql = context.Videos
.Include(v => v.Versions)
.Where(v => v.Versions.Any(vers => vers.Available))
.ToString();
Edit
Most likely a query with raw sql won't populate navigation properties, so it doesn't seem to be possible to use it for eager loading. See the discussion here, in the answer and its comments.

Dynamically building CAML query in SharePoint 2010

I have an requirement of get the items from the list depends on the ItemID.I have list which contains 5000 items in which I retrieve only 1000 items for that I will dynamically build the CAML query using JohnHoliday CAML.NET and the query have 1000 conditions at that time I got Value does not fall within the Expected Range error. The query works fine upto 150 items but it throws error when the ItemID increases.Could you provide a suitable workaround for this issue ?
You're running into the size limit for CAML queries, which AFAIK isn't documented anywhere, but definitly exists.
If you only need to support 2010 then you can use the new <In> operator which probably with get you a bid further
In sharepoint 2010 there is a List view threshold configuration that give the administrator the ability to determine the maximum items you can retreive in a one patch
and to overcome this problem you can use
ContentIterator
check this link for more help
Why not iterate over SPList.Items and take which items you need? So there's no need to build a complex caml query. Or call SPList.GetItemByUniqueId.

Subsonic 2.2 InnerJoin Across Two Databases

Can anyone provide an example of how to join across two schemas using subsonic 2.2.
This doesn't work:
SqlQuery qu = new Select("*")
.From(NorthwindLeads.Lead.Schema)
.InnerJoin(Northwind.StatsMap.SourceIdColumn, NorthwindLeads.Lead.SourceIdColumn);
There's no easy way to do this in subsonic that I'm aware of. I would recommend adding a view to your database which returns the data you want from the other schema and then joining to the view in your subsonic query.

Resources