ComponentOne Data Source for Entity Framework
ComponentOne LiveLinq / How to Use LiveLinq / Query Collection
In This Topic
    Query Collection
    In This Topic

    To use LiveLinq in Visual Studio, start by adding the LiveLinq assembly, C1.LiveLinq.dll, to your project's References. Then add the 'using' directives to the source file that will enable you to use LiveLinq in code:

    C#
    Copy Code
    using C1.LiveLinq;
    using C1.LiveLinq.Indexing;
    using C1.LiveLinq.Collections;
    
         

    (Not all of them are always necessary, but let's put all of them there at once for simplicity)

    In order to query a collection in LiveLinq, we need to wrap it in an interface IIndexedSource<T> that will tell LiveLinq to take over. Otherwise, standard LINQ will be used. This wrapping is done with a call to the AsIndexed extension method, for example:

    C#
    Copy Code
    from c in source.AsIndexed() where c.p == 1 select source
    
         

    However, not every collection can be wrapped this way. For instance, if we try this with a List<T> source, we'll get a compilation error. To be usable in LiveLinq, a collection must support change notifications, it must notify LiveLinq when changes are made to its objects and when objects are added to or deleted from the collection. This requirement is satisfied for collections used for data binding, that is, implementing either IBindingList (WinForms data binding) or INotifyCollectionChanged/INotifyPropertyChanged (WPF data binding)

    In particular, AsIndexed() is applicable to ADO.NET collections (DataTable, DataView) and to LINQ to XML collections.

    See Also