jeudi 5 octobre 2017

Convert Expression

I would like to create repository pattern class which gets items by query. Unfortunately I need to parse this query from one class to another (Picture to ListItem) to send it to a server(api). So my code should looks like below:

    public static void ConvertQuery(Expression<Func<Picture, object>> oldQuery)
    {
        Expression<Func<ListItem, object>> newQuery = convert(oldQuery);
    }

And, for example, i want to convert old query by cast properties like below:

  • SomePicture.Id => SomeListItem.Id
  • SomePicture.FileName => SomeListItem["FileName"]

I found some solutions where I can cast properties. But the biggest problem is with casting one property to dictionary field (item1.Filename to item2.["Filename"]





Aucun commentaire:

Enregistrer un commentaire