LinQ

Cross Join

    var q = 
        from c in categories 
        join p in products on c equals p.Category 
        select new { Category = c, p.ProductName };  

Group Join

   var q = 
        from c in categories 
        join p in products on c equals p.Category into ps 
        select new { Category = c, Products = ps };  

Left Outer Join

    var q = 
        from c in categories 
        join p in products on c equals p.Category into ps 
        from p in ps.DefaultIfEmpty() 
        select new { Category = c, ProductName = p == null ? "(No products)" : p.ProductName }; 
Opublikowano c# | Otagowano | Skomentuj

AJAX Request vc RedirectToRouteResult

            if (filterContext.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                //Return JSON
                filterContext.Result = new JsonResult
                {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    Data = new { error = true, message = "Sorry, an error occurred while processing your request." }
                };
            }
            else
            {
                //Redirect user to error page
                filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary(
                new { Controller = "Error", Action = "Index" }));
            }
Opublikowano asp.net mvc | Otagowano | Skomentuj