列表<user>不使用Ria服务生成的属性</user>

时间:2011-11-24 16:52:53

标签: silverlight ria

我有一个RIA服务,我发现我的常规属性是为RIA服务生成的(例如:string,int等)。

我有一个自定义类型用户,如下所述。我的List属性不是作为Ria服务的一部分生成的。有什么想法吗?

下面的示例显示了在RIA服务中没有生成的属性,后跟User类

    public List<User> Users
    {
        get
        {
            if(this.users == null)
            {
                this.users = new List<User>();
            }
            return this.users;
        }
        set
        {
            this.users = new List<User>(value);
        }
    }





using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ServiceModel.DomainServices.Server;

namespace MyNamespace
{
    public class User
    {
        [Key]
        public int? Id { get; set; }

        public string Login { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string DisplayName { get; set; }

        public string Email { get; set; }

        public string Title
        {
            get;
            set;
        }

        public string Department
        {
            get;
            set;
        }

        public string Password { get; set; }

        public string Source { get; set; }

        public bool? IsEnabled { get; set; }

        public bool IsInstanceAdmin { get; set; }

        public byte[] Image { get; set; }

        //public bool IsDeleted { get; set; }

        private IList<UserGroupMembership> _userGroups;

        /// <summary>
        /// Gets or sets the user groups.
        /// </summary>
        /// <value>The user groups.</value>
        [Include]
        [Association("UserGroups", "Id", "UserId")]
        public IList<UserGroupMembership> UserGroups
        {
            get
            {
                if (_userGroups == null)
                {
                    _userGroups = new List<UserGroupMembership>();
                }
                return _userGroups;
            }
            set
            {
                _userGroups = value;
            }
        }


        private IList<RoleAssignment> _roleIdentity;

        /// <summary>
        /// Gets or sets the role identities.
        /// </summary>
        /// <value>The role identities.</value>
        [Include]
        [Association("RoleIdentities", "Id", "UserId")]
        public IList<RoleAssignment> RoleAssignments
        {
            get
            {
                if (_roleIdentity == null)
                {
                    _roleIdentity = new List<RoleAssignment>();
                }
                return _roleIdentity;
            }
            set
            {
                _roleIdentity = value;
            }
        }


    }
}

1 个答案:

答案 0 :(得分:0)

是否有用户查询将其公开给客户端?因为您无法通过POCO对象公开任何域服务类型!它必须位于域服务中的查询中。

相关问题