Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net Breeze、数据库优先和匿名对象_Asp.net_Entity Framework_Breeze - Fatal编程技术网

Asp.net Breeze、数据库优先和匿名对象

Asp.net Breeze、数据库优先和匿名对象,asp.net,entity-framework,breeze,Asp.net,Entity Framework,Breeze,我正在使用ASP.Membership提供程序,并为用户数据创建了一个附加表。我只是在试验,我不担心安全性或类似的问题。我只关心全局 我正在试验Breeze、SPA、Entity Framework和Web.API,也许在我掌握好各个概念之前,我的速度太快了 我的Breeze查询如下所示: [HttpGet] public IQueryable<object> Users() { return ( from user in _contextProvider.C

我正在使用ASP.Membership提供程序,并为用户数据创建了一个附加表。我只是在试验,我不担心安全性或类似的问题。我只关心全局

我正在试验Breeze、SPA、Entity Framework和Web.API,也许在我掌握好各个概念之前,我的速度太快了

我的Breeze查询如下所示:

[HttpGet]
public IQueryable<object> Users()
{
    return (
        from user in _contextProvider.Context.Users
        join membership in _contextProvider.Context.Memberships on user.UserId equals membership.UserId
        join userProfile in _contextProvider.Context.UserProfiles on user.UserId equals userProfile.UserId
        select new { user, membership, userProfile}
    );
}
[HttpGet]
公共IQueryable用户()
{
返回(
来自_contextProvider.Context.Users中的用户
在user.UserId上加入_contextProvider.Context.Memberships中的成员资格等于membership.UserId
在user.UserId上的_contextProvider.Context.UserProfiles中加入userProfile等于userProfile.UserId
选择新{用户、成员、用户配置文件}
);
}
我的结果如下所示(仅显示第一条记录):

{
$id:“1”,
$type:“f__匿名类型4`3[[SPA01.EntityFramework.User,SPA01],[SPA01.EntityFramework.Membership,SPA01],[SPA01.EntityFramework.UserProfile,SPA01],
用户:{
$id:“2”,
$type:“SPA01.EntityFramework.User,SPA01”,
用户ID:“dd59fcd1-9d88-4494-a37c-1c25155cb77d”,
应用程序ID:“23042eba-1113-4e56-8ac6-4640120ecc6c”,
用户名:“DHaworth”,
IsAnonymous:错,
最后活动日期:“2014-02-17T00:01:39.707”,
成员:{
$id:“3”,
$type:“SPA01.EntityFramework.Membership,SPA01”,
用户ID:“dd59fcd1-9d88-4494-a37c-1c25155cb77d”,
应用程序ID:“23042eba-1113-4e56-8ac6-4640120ecc6c”,
密码:“sdfasdfsadfsadfsadfsafae0dfzt64vo=“,
密码格式:1,
密码salt:“/CRUMPNf9+byEdPraeasfsaQJw==”,
电子邮件:“MyEmail@hotmail.com",
密码问题:“TR”,
密码回答:“B4HOezQ/TYasdfasfasfgjz4oAOERhnc=“,
我同意:是的,
IsLockedOut:false,
创建日期:“2014-01-04T05:18:18.063”,
LastLoginDate:“2014-02-17T00:01:39.707”,
LastPasswordChangedDate:“2014-01-12T21:58:30.497”,
最后锁定日期:“1754-01-01T00:00:00.000”,
FailedPasswordAttemptCount:0,
FailedPasswordAttemptWindowsStart:“1754-01-01T00:00:00.000”,
FailedPasswordAnswerAttemptCount:0,
FailedPasswordAnswerAttemptWindowsStart:“1754-01-01T00:00:00.000”,
注释:空,
用户:{
$ref:“2”
}
},
用户配置文件:{
$id:“4”,
$type:“SPA01.EntityFramework.UserProfile,SPA01”,
用户ID:“dd59fcd1-9d88-4494-a37c-1c25155cb77d”,
名字:“杜安”,
姓:“霍沃斯”,
用户:{
$ref:“2”
}
},
角色:[]
},
成员:{
$ref:“3”
},
用户配置文件:{
$ref:“4”
}
},

我正在创建一个用户管理屏幕,在这里我将显示所有三个表中的信息

我可以在使用JsonResultsAdapter的同时使用Breeze,还是需要先在实体框架方面做些什么


感谢您,Breeze支持这种开箱即用的场景(将实体包装在匿名对象中);不需要额外的工作。例如,请参见。Breeze客户端需要有元数据来处理实体,但是如果您使用EF和
EFContextProvider
,这没有问题

{
$id: "1",
$type: "<>f__AnonymousType4`3[[SPA01.EntityFramework.User, SPA01],[SPA01.EntityFramework.Membership, SPA01],[SPA01.EntityFramework.UserProfile, SPA01]], SPA01",
user: {
    $id: "2",
    $type: "SPA01.EntityFramework.User, SPA01",
    UserId: "dd59fcd1-9d88-4494-a37c-1c25155cb77d",
    ApplicationId: "23042eba-1113-4e56-8ac6-4640120ecc6c",
    UserName: "DHaworth",
    IsAnonymous: false,
    LastActivityDate: "2014-02-17T00:01:39.707",
    Membership: {
        $id: "3",
        $type: "SPA01.EntityFramework.Membership, SPA01",
        UserId: "dd59fcd1-9d88-4494-a37c-1c25155cb77d",
        ApplicationId: "23042eba-1113-4e56-8ac6-4640120ecc6c",
        Password: "sdfasdfsadfsadfsafasfae0dfzT64vo=",
        PasswordFormat: 1,
        PasswordSalt: "/CRUMPNf9+byEdPraeasfsaQJw==",
        Email: "MyEmail@hotmail.com",
        PasswordQuestion: "TR",
        PasswordAnswer: "B4HOezQ/TYasdfasfasfgjz4oAOERhnc=",
        IsApproved: true,
        IsLockedOut: false,
        CreateDate: "2014-01-04T05:18:18.063",
        LastLoginDate: "2014-02-17T00:01:39.707",
        LastPasswordChangedDate: "2014-01-12T21:58:30.497",
        LastLockoutDate: "1754-01-01T00:00:00.000",
        FailedPasswordAttemptCount: 0,
        FailedPasswordAttemptWindowStart: "1754-01-01T00:00:00.000",
        FailedPasswordAnswerAttemptCount: 0,
        FailedPasswordAnswerAttemptWindowsStart: "1754-01-01T00:00:00.000",
        Comment: null,
        User: {
            $ref: "2"
        }
    },
    UserProfile: {
            $id: "4",
            $type: "SPA01.EntityFramework.UserProfile, SPA01",
            UserId: "dd59fcd1-9d88-4494-a37c-1c25155cb77d",
            FirstName: "Duane",
            LastName: "Haworth",
            User: {
            $ref: "2"
            }
    },
    Roles: [ ]
},
membership: {
        $ref: "3"
},
userProfile: {
        $ref: "4"
}