小编Ale*_*edo的帖子

LINQ to Entities无法识别方法'Method name'方法

我遇到了类似的问题: LINQ to Entities无法识别方法'System.String ToString()'方法,并且此方法无法转换为存储表达式

我正在尝试对我的源进行分页,但在我的情况下,我不能将结果GetPropertyValue放在变量中,因为我需x要这样做:

public IEnumerable<TModel> Paginate(IQueryable<TModel> source, ref int totalPages, int pageIndex, int pageSize, string sortfield, SortDirection? sortdir)
{
    totalPages = (int)Math.Ceiling(source.Count() / (double)pageSize);

    if (sortdir == SortDirection.Descending)
    {
         return source.OrderByDescending(x => GetPropertyValue(x, sortfield)).Skip(pageIndex * pageSize).Take(pageSize).ToList();
    }
    else
    {
         return source.OrderBy(x => GetPropertyValue(x, sortfield)).Skip(pageIndex * pageSize).Take(pageSize).ToList();
    }
}

private static object GetPropertyValue(object obj, string name)
{
    return obj == null ? null : obj.GetType().GetProperty(name).GetValue(obj, null);
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我该怎么办?

c# linq iqueryable

7
推荐指数
1
解决办法
4838
查看次数

剪辑到绘制的路径

我正在尝试绘制一条路径,并将它用作我画布的面具.

'use strict';

var canvas = new fabric.Canvas('c', {
    hoverCursor: 'pointer',
    isDrawingMode: true
});

canvas.freeDrawingBrush = new fabric.PencilBrush(canvas);
canvas.freeDrawingBrush.color = '#000';
canvas.freeDrawingBrush.width = 100;

fabric.Image.fromURL('http://fabricjs.com/assets/pug_small.jpg', function(img) {

    canvas.add(img);
    canvas.setWidth(img.getWidth());
    canvas.setHeight(img.getHeight());
    canvas.centerObject(img);
    img.selectable = false;
});

canvas.on('path:created', function(data) {

    var path = data.path;

    canvas.remove(path);
    canvas.clipTo = function(context) {
        path.render(context);
    };

    canvas.isDrawingMode = false;
    canvas.renderAll();
});
Run Code Online (Sandbox Code Playgroud)

如何使整个路径成为图像的可见区域?

http://jsfiddle.net/db45yhpo/

编辑

这是我想要实现的,但使用FabricJS.

http://www.createjs.com/demos/easeljs/alphamaskreveal

canvas html5-canvas fabricjs

7
推荐指数
1
解决办法
336
查看次数

递归菜单指令

我正在尝试使用angularJS做一个递归菜单,但我不断收到错误:超出最大调用堆栈大小

我的指示:

angular.module("application").directive("navigation", [function () {
            return {
                restrict : 'E',
                replace : true,
                scope : {
                    menu : '='
                },
                template : '<ul><navigation-item ng-repeat="item in menu" submenu="item"></navigation-item></ul>',
                link : function ($scope, elem, attrs) {}
            }
        }
    ]);


angular.module("application").directive("navigationItem", [function () {

            return {
                restrict : 'E',
                replace : true,
                scope : {
                    submenu : '='
                },
                template : '<li>{{ submenu }}<navigation menu="submenu.Children"></navigation></li>',
                link : function ($scope, elem, attrs) {}
            }
        }
    ]);
Run Code Online (Sandbox Code Playgroud)

我的控制器:

app.controller('myController', ['$scope', function (ng) { …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-directive

6
推荐指数
1
解决办法
1万
查看次数

在项目中捆绑包含文件

我有一个Visual Studio解决方案,其中包含2个项目(网站):

Solution
  - Project A
      - App_Start
         - BundleConfig.cs
      - Scripts

  - Project B
      - App_Start
      - Scripts
         - my_file.js
Run Code Online (Sandbox Code Playgroud)

有没有办法使用捆绑包包含来自Project Bat的文件Project A

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(
         new ScriptBundle("~/bundles/my_bundle")
              // This obviously doesn't work
              .Include("~/../Scripts/my_file.js")

              // Neither does this
              .Include("../../../Scripts/my_file.js")
  );
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc bundle

5
推荐指数
1
解决办法
1448
查看次数

在Web Api 2中启用会话

我知道REST应该是无状态的.

我的Web Api与我的MVC网站的同一个项目.我如何分享他们之间的会话?

我正在尝试使用Web Api 2的好东西并使用Ajax而不是构建RESTful API.

c# asp.net-web-api

4
推荐指数
1
解决办法
1万
查看次数

自动增量字符串

我正在尝试建立一个类别的分类列表,如下所示:

1 Category
  1.1 Children
  1.2 Children
      1.2.1 Children
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

$a = "1.1";
echo ++$a; // 2.1

$b = "1.1.1";
echo ++$b; // 1.1.2
Run Code Online (Sandbox Code Playgroud)

为什么$a递增到2.1,而不是1.2$b

php auto-increment

2
推荐指数
1
解决办法
79
查看次数