解析,如果未设置objectid,如何获得关系

时间:2015-03-24 23:53:38

标签: c# parse-platform relation

我有一个问题,我的关系不断返回零关系对象(在这种情况下是银行帐户)。 有人可以快速查看我的代码,看看我是否做错了什么? 属性中业务逻辑的原因是由于数据库和业务逻辑的分离。

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using OpenFridge.Portable.Data.Interfaces.Entities;
using OpenFridge.Portable.Data.Parse.Entities;
using Parse;
using AutoMapper;

namespace OpenFridge.Portable.Data.Parse.Entities
{
    [ParseClassName("_User")]
    public class ParseUserEntity : ParseUserEntityBase, IUserEntity
    {
        private string _password;
        [ParseFieldName("password")]
        public new string Password
        {
            get { return _password; }
            set
            {
                _password = value;
                base.Password = value;
            }
        }

        Lazy<IEnumerable<IBankAccountEntity>> _bankAccounts;
        [ParseFieldName("bankAccounts")]
        public Lazy<IEnumerable<IBankAccountEntity>> BankAccounts
        {
            get
            {
                var relation = GetRelation<ParseBankAccountEntity>("bankAccounts");

                if (relation == null) 
                    return null;

                var _bankAccounts = new Lazy<IEnumerable<IBankAccountEntity>>(() => relation.Query.FindAsync().Result);

                return _bankAccounts;
            }
            set
            {
                _bankAccounts = value;
            }
        }
    }
}

我怀疑由于这个原因,这种情况一直是空的 在BankAccounts代码执行之前,this.ObjectId尚未设置。 关于如何使这个工作的任何想法?

0 个答案:

没有答案