123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Linq;
- using InABox.Clients;
- using InABox.Core;
- namespace Comal.Classes
- {
- public class SupplierLookups : EntityLookup<Supplier>, ILookupDefinition<Supplier, Product>
- {
- public Filter<Supplier> DefineFilter(Product[] items)
- {
- var item = items?.SingleOrDefault();
- var suppliers = new Client<SupplierProduct>().Query(
- new Filter<SupplierProduct>(x => x.Product.ID).IsEqualTo(item.ID),
- new Columns<SupplierProduct>(x => x.SupplierLink.ID));
- var ids = suppliers.Rows.Select(r => r.Get<SupplierProduct, Guid>(x => x.SupplierLink.ID)).ToArray();
- return new Filter<Supplier>(x => x.ID).InList(ids);
- }
- Columns<Product> ILookupDefinition<Supplier, Product>.DefineFilterColumns()
- => new Columns<Product>(x => x.ID);
- public override Columns<Supplier> DefineColumns()
- {
- return new Columns<Supplier>(
- x => x.ID,
- x => x.Code,
- x => x.Name
- );
- }
- public override Filter<Supplier> DefineFilter()
- {
- return null;
- }
- public override SortOrder<Supplier> DefineSortOrder()
- {
- return new SortOrder<Supplier>(x => x.Code);
- }
- }
- }
|