我是EF的新手,我正在尝试使用从我的数据库类型转换User为我的信息类的扩展方法UserInfo.
如果这有所作为,我首先使用数据库?
我的代码给出了错误
由于已经处理了DbContext,因此无法完成操作.
try
{
IQueryable<User> users;
using (var dataContext = new dataContext())
{
users = dataContext.Users
.Where(x => x.AccountID == accountId && x.IsAdmin == false);
if(users.Any() == false)
{
return null;
}
}
return users.Select(x => x.ToInfo()).ToList(); // this line is the problem
}
catch (Exception ex)
{
//...
}
Run Code Online (Sandbox Code Playgroud)
我可以看到为什么它会这样做,但我也不明白为什么where语句的结果没有被保存到users对象中?
所以我想我的主要问题是为什么它不起作用,其次是什么是使用扩展方法和EF的正确方法?
有没有办法检查空格键是否同时跟踪鼠标的移动方向和距离等等.
这点是我要复制Photoshop按住空格键,鼠标左键并移动鼠标时的滚动方式,但无需按住鼠标左键.
我正在尝试使用Bearer令牌和owin进行身份验证.
我可以使用授权类型发出令牌password并GrantResourceOwnerCredentials在AuthorizationServerProvider.cs中重写.
但我无法使用该Authorize属性访问控制器方法.
这是我的代码:
Startup.cs
public class Startup
{
public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
// normal
public Startup() : this(false) { }
// testing
public Startup(bool isDev)
{
// add settings
Settings.Configure(isDev);
OAuthOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/Token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new AuthorizationServerProvider()
};
}
public void Configuration(IAppBuilder app)
{
// Configure the db context, user manager and role manager …Run Code Online (Sandbox Code Playgroud) 我现在看到很多网站,主要是有大量图片的教程网站,一旦进入视口,他们只会在页面下方加载图片?
我该怎么做呢?
一个例子:
http://www.chopeh.com/blog/logo-design-start-to-finish/
向下滚动页面时,视口下方的图像会淡入
小提琴可以在这里找到.
我正在添加一个由它映射的可观察数组ko.mapping.fromJS().
在我看来,我正在使用数组上的属性构建一个URL attr: { href: '/Users/Summary?userId=' + ID() }.
如果我想在我正在使用的数组中添加一个项目self.Users.push().
如果我这样做,我会收到错误ID is not a function.
所以我的问题是将数据添加到数组的正确方法,还是我没有href正确构建attr?