В JQuery можно звонить
$("form:first").trigger("submit")
, не знают, намного лучше ли это. Я думаю form.submit (); довольно универсально.
You just cannot do that, sadly. Collection properties generated for LINQ to SQL entity classes are not IQueryable
; therefore, any queries performed on them will be using LINQ to Objects. This is by design. As you rightly note yourself, to get efficient query you have to query over Transactions
taken from your DataContext
, but you don't have one in your property gettor.
At this point your options are either:
DataContext
as argument; or EntitySet
s on it do, albeit indirectly - naturally this is version specific, prone to breakage, etc.So far as I know, Entity Framework does not have this limitation, since its collection properties are ObjectQuery
- which is IQueryable
.
What is the type of Transactions in the first example?
Remember you are using Extension Methods. The Linq Extension Methods that are used are dependant on the interface Transactions implements:
Edit:
This is the fingerprint of the EntitySet type:
public sealed class EntitySet<TEntity> : IList,
ICollection, IList<TEntity>, ICollection<TEntity>, IEnumerable<TEntity>,
IEnumerable, IListSource
where TEntity : class
To answer your questions:
Переключитесь с использования IEnumerable на IQueryable, и ваш SQL будет оптимизирован так, чтобы получать только по запросу то, что вам нужно.