ServiceStack AutoQuery部分响应返回不需要的GUID,int等

时间:2015-08-14 13:12:16

标签: c# servicestack

我正在研究ServiceStack对AutoQuery的部分响应,代码片段如下:

public class SalesOrderServices : MyService
    {
        Utilities.RequestUtilities utilities = new Utilities.RequestUtilities();

        public object Any(SalesOrdersGet request)
        {
            String qString = GetSelectString(base.Request);

            var q = AutoQuery.CreateQuery(request, Request.GetRequestParams());

            if (!qString.IsNullOrEmpty())
            {
                q.Select(qString);
            }

            return AutoQuery.Execute(request, q);
        }

继承了MyService

namespace WombatWS.ServiceInterface.Sales
{
    public class MyService : Service
    {
        public IAutoQuery AutoQuery { get; set; }

        public String GetSelectString(IRequest request)
        {
            String qString = "";

            if (!request.QueryString["fields"].IsNullOrEmpty())
            {
                String sFields = request.QueryString["fields"].ToString();
                String[] properties = sFields.Split(',');

                foreach (String s in properties)
                {
                    if (!s.Equals(properties.Last().ToString()))
                    {
                        qString += s + ",";
                    }
                    else
                    {
                        qString += s;
                    }
                }
            }
            return qString;
        }
    }
}

我注意到除了我放入?field={field1},{field2}...的有趣字段之外,不需要的DateTime将按原样返回,以及所有int,GU​​ID类型也将返回为0,0000-000000000-0000- 00000的东西。如何摆脱它们?感谢。

0 个答案:

没有答案