Ejemplo n.º 1
0
        public static string GetUrl(CGrid <T> grid, string url, params object[] keys)
        {
            var keyNames = grid.GetPrimaryKeys();

            string expandParameters = grid.CurrentExpandODataProcessor.Process();

            if (url.Contains("?"))
            {
                expandParameters = "&" + expandParameters;
            }
            else
            {
                expandParameters = "?" + expandParameters;
            }

            if (keyNames.Length != keys.Length || keys.Length == 1)
            {
                return(url + "(" + string.Join(",", keys.Select(x => x.GetType() == typeof(string) ? "'" + x + "'" : x.ToString())) + ")" + expandParameters);
            }
            else
            {
                var keysUrl = new List <string>();;
                for (int i = 0; i < keys.Length; i++)
                {
                    keysUrl.Add(keyNames[i] + "=" + (keys[i].GetType() == typeof(string) ? "'" + keys[i] + "'" : keys[i].ToString()));
                }
                return(url + "(" + string.Join(",", keysUrl.Select(x => x.ToString())) + ")" + expandParameters);
            }
        }