public static Contact Load(this IContactService service, int id, Action<IProjection<Contact>> projection)
        {
            var contactProjection = new Projection<Contact>();
            projection(contactProjection);

            return service.Load(id, contactProjection.Build());
        }
Ejemplo n.º 2
0
        public static IEnumerable <T> Query <T>(this IDataService service, string apiKey, DataPage page,
                                                Action <IQueryBuilder <T> > queryBuilder,
                                                Action <IProjection <T> > fieldSelection, string orderBy, bool asc) where T : ITable, new()
        {
            var query = new QueryBuilder <T>();

            queryBuilder(query);

            var projection = new Projection <T>();

            fieldSelection(projection);

            XmlRpcStruct data = query.Dictionary.AsXmlRpcStruct();

            string[] selectedFields = projection.Build();

            var wrapper = new DataServiceWrapperCustom(apiKey);

            if (String.IsNullOrEmpty(orderBy))
            {
                return(wrapper.Invoke <IEnumerable <object>, T[]>(d => d.Query(apiKey,
                                                                               typeof(T).Name, page.Size,
                                                                               page.Number, data, selectedFields)));
            }
            else
            {
                return(wrapper.Invoke <IEnumerable <object>, T[]>(d => d.Query(apiKey,
                                                                               typeof(T).Name, page.Size,
                                                                               page.Number, data, selectedFields, orderBy, asc)));
            }
        }
        public static IEnumerable<Contact> FindByEmail(this IContactService service, string email,
                                                       Action<IProjection<Contact>> fieldSelection)
        {
            var projection = new Projection<Contact>();
            fieldSelection(projection);

            return service.FindByEmail(email, projection.Build());
        }