在编辑器中将字段名称转换为驼峰式

时间:2019-07-16 04:36:12

标签: asp.net-mvc editor

我从https://editor.datatables.net/购买了编辑器,并编写以下代码以在Json中获得销售订单行。某些字段的返回结果无法转换为驼峰格式。谁能告诉我怎么做? 我已经在WebApiConfig文件中将Camel Case设置为Formatting.Indented。

谢谢。

最好的问候, 汤姆

型号:

public class SalesOrderLineDto
    {

        public int Id { get; set; }
        public string OrderNo { get; set; }
        public string OrderType { get; set; }
        public int LineNo { get; set; }
        public string PartNo { get; set; }
        public string Description { get; set; }
        public int OrderQuantity { get; set; }
        public int OpenQuantity { get; set; }
        public int FirstOrderQuantity { get; set; }
        public decimal UnitPrice { get; set; }
        public decimal Amount { get; set; }
        public string SupplierOrderNo { get; set; }
        public string SupplierOrderType { get; set; }
        public int SupplierOrderLineNo { get; set; }
        public string Status { get; set; }
        public int SupplierOrderLineId { get; set; }
        public string CustomerPartNo { get; set; }
        public int SalesOrderMasterId { get; set; }
        public DateTime RequestDate { get; set; }
    }

API编码:

public IHttpActionResult SalesOrderLines(string orderNo)
        {
            var request = HttpContext.Current.Request;
            var settings = Properties.Settings.Default;
            using (var tcdb = new DataTables.Database(settings.DbType, settings.DbConnection))
            {
                var response = new Editor(tcdb, "data.SalesOrderLine")
                    .Model<SalesOrderLineDto>()
                    .Where("orderno" ,orderNo,"=")
                    .Field(new Field("partNo")
                    .Validator(Validation.NotEmpty())
                    )
                    .Field(new Field("description")
                    .Validator(Validation.NotEmpty())
                    )
                    .Field(new Field("orderQuantity")
                    .Validator(Validation.Numeric())
                    )
                    .Field(new Field("unitPrice")
                    .Validator(Validation.Numeric())
                    )
                    .Field(new Field("amount")
                    .Validator(Validation.Numeric())
                    )
                    .Field(new Field("requestDate")
                    .Validator(Validation.DateFormat(
                           Format.DATE_ISO_8601,
                            new ValidationOpts { Message = "Please enter a date in the format yyyy-mm-dd" }
                        ))
                        .GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
                        .SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
                    )
                    .Process(request)
                    .Data();

                return Json(response);
            }

API结果:

{
    "draw": null,
    "data": [
        {
            "DT_RowId": "row_1",
            "partNo": "Part No 12345",
            "description": "The first good description",
            "orderQuantity": "1000",
            "unitPrice": "1.3000",
            "amount": "1300.0000",
            "requestDate": "2019-07-02",
            "Id": null,
            "OrderNo": "14",
            "OrderType": "SD",
            "LineNo": 1,
            "PartNo": null,
            "Description": null,
            "OrderQuantity": null,
            "OpenQuantity": 1000,
            "FirstOrderQuantity": 1000,
            "UnitPrice": null,
            "Amount": null,
            "SupplierOrderNo": "1",
            "SupplierOrderType": "PO",
            "SupplierOrderLineNo": 1,
            "Status": "100",
            "SupplierOrderLineId": 1,
            "CustomerPartNo": "CustPartNo133",
            "SalesOrderMasterId": 14,
            "RequestDate": null
        }
    ],
    "recordsTotal": null,
    "recordsFiltered": null,
    "error": null,
    "fieldErrors": [],
    "id": null,
    "meta": {},
    "options": {},
    "files": {},
    "upload": {
        "id": null
    },
    "debug": null,
    "cancelled": []
}

0 个答案:

没有答案