TheWheel.OpenXml.WebApi

当前版本: 1.184.0


TheWheel.OpenXml.WebApi是什么?

添加新的web api格式化程序以处理xslx中的呈现。
Adds a new web api formatter to handle rendering in xslx

安装方式

Install-Package TheWheel.OpenXml.WebApi -Version 1.184.0

相关网址


TheWheel.OpenXml.WebApi使用说明

Build status

thewheel-dotnet

Stop reinventing the wheel. It's here ;)

Lamda features

Helps you to build lambda expression easily.

  • And or Or on constraints (a=> a.X).And(b=>b.Y)
  • Combine Dto building
  • Dynamically access properties or properties path on objects o.Property("Property1.Property2")

Simple And/Or between 2 lambda

How is it to merge the following conditions ?

Expression<Func<A,bool>> condition1=a=>a.Property1=="toto";
Expression<Func<A,bool>> condition2=a=>a.Property2=="titi";

That simple :

    var condition=condition1.And(condition2);

Combine Dto building

Let's assume you have the following class :

public class Person
{
    public static Expression<Func<User, Person>> ToList=u=>new Person
    {
      Id=u.Id,
      FullName=u.FullName,
      Mail=u.Mail,
    };
    
    public static Expression<Func<User, Person>> ToDetails=u=>new Person
    {
      Id=u.Id,
      FullName=u.FullName,
      Mail=u.Mail,
      Phone=u.Phone,
      FirstName=u.FirstName,
      LastName=u.LastName
    };
    
    public int Id { get; set; }
    public string FullName { get; set; }
    public string Mail { get; set; }
    public string Phone { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

Painful to maintain both expression isn't it ? Here is what TheWheel allows you to do :

public class Person
{
    public static Expression<Func<User, Person>> ToList=u=>new Person
    {
      Id=u.Id,
      FullName=u.FullName,
      Mail=u.Mail,
    };
    
    public static Expression<Func<User, Person>> ToDetails=ToList.Combine(u=>new Person
    {
      Phone=u.Phone,
      FirstName=u.FirstName,
      LastName=u.LastName
    });
    
    public int Id { get; set; }
    public string FullName { get; set; }
    public string Mail { get; set; }
    public string Phone { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

You only need to maintain delta between the basic list and the full details.

Apply lambda on single class

Let's assume you have the class defined in the previous sample and the following one :

public class Car
{
    public static Expression<Func<Vehicle, Car>> ToList=v=>new Car
    {
      Id=v.Id,
      Color=v.Color,
      Brand=v.Brand.Name,
      Model=v.Model,
      Owner=new Person{
        Id=v.Owner.Id,
        FullName=v.Owner.FullName,
        Mail=v.Owner.Mail,
      }
    };
    
    public string Id { get; set; }
    public string Color { get; set; }
    public string Brand { get; set; }
    public string Model { get; set; }
    public Person Owner { get; set; }
}

You will say : Hey I have already written such a thing ! You're right, then, let's factorize thanks to TheWheel

public class Car
{
    public static Expression<Func<Vehicle, Car>> ToList=ReflectionExpression.PreCompile<Vehicle, Car>(a => new Car
    {
      Id=v.Id,
      Color=v.Color,
      Brand=v.Brand.Name,
      Model=v.Model,
      Owner=v.Owner.AsLambda(Person.ToList).AsCompilable(),
    }).AsExpression();
    
    public string Id { get; set; }
    public string Color { get; set; }
    public string Brand { get; set; }
    public string Model { get; set; }
    public Person Owner { get; set; }
}

You only need to maintain delta between the basic list and the full details.

项目热度

项目信息

分享到

基本信息
开发语言
C#
相关项目
0
相关仓库
0
Watchers
1
Stars
2
Forks
1
版本数量
51
最新发布
2018-12-20
首次发布
2015-05-12
仓库大小
11 MB

版本历史
1.184.0
2018-12-20
1.181.0
2018-12-19
1.157.0
2018-07-06
1.155.0
2017-12-18
1.154.0
2017-12-14
1.152.0
2017-12-13
1.151.0
2017-08-04
1.150.0
2017-08-04
1.149.0
2017-08-04
1.147.0
2017-08-04

贡献者
Nicolas Penin