I have sent you and email with all required libs to Dmitri's email. So the Code should be copy/pasted into the appropriate place in the Program class:

First one:

using (var tr = s.OpenTransaction())
{
   var item = new OperatorAuthority(Guid.NewGuid());
   var subaccount = new DepoSubaccount(Guid.NewGuid());

   var fields2 = (from multiLink in item.MlDepositorAuthorities
    let tempQueSubaccount =
        multiLink.Linked.MlSubaccounts.Any()
            ? multiLink.Linked.MlSubaccounts.Select(ml => ml.Linked)
            : multiLink.Linked.PassiveAccount.DepoSubaccounts.Select(ss => ss)
    where subaccount.In(tempQueSubaccount)
    select
        new
        {
            BeginDate = multiLink.Linked.DocumentDateBegin,
            EndDate = multiLink.Linked.DocumentDateEnd
        });

   Assert.DoesNotThrow(() => fields2.ToArray());

   tr.Complete();
}

Another one:

using (var tr = s.OpenTransaction())
{
    var expression = BindAuthoritiesToPassiveAccount1(Guid.NewGuid());
    var fields = Query.All<AuthorityBase>().Where(expression);

    Assert.DoesNotThrow(() => fields.ToArray());

    var expression2 = BindAuthoritiesToPassiveAccount2(Guid.NewGuid());
    var fields2 = Query.All<AuthorityBase>().Where(expression2);

    Assert.DoesNotThrow(() => fields2.ToArray());

    tr.Complete();
}

public static Expression<Func<AuthorityBase, bool>> BindAuthoritiesToPassiveAccount1(Guid passiveAccountId)
{
    var passiveAccount = Session.Current.Query.SingleOrDefault<PassiveAccount>(passiveAccountId);

    return authority =>
           (authority is RegulationAuthority && authority.DocumentIssuer == passiveAccount.AccountOwner) ||
           (authority is DepositorAuthority && (authority as DepositorAuthority).PassiveAccount == passiveAccount) ||
           (authority is OperatorAuthority && (authority as OperatorAuthority).MlPassiveAccounts.Any(ml => ml.Linked == passiveAccount));
}

public static Expression<Func<AuthorityBase, bool>> BindAuthoritiesToPassiveAccount2(Guid passiveAccountId)
{
    var passiveAccount = Session.Current.Query.SingleOrDefault<PassiveAccount>(passiveAccountId);

    return authority =>
           (authority is RegulationAuthority && authority.DocumentIssuer == passiveAccount.AccountOwner) ||
           (authority is DepositorAuthority && (authority as DepositorAuthority).PassiveAccount == passiveAccount) ||
           (authority is OperatorAuthority &&
            Session.Current.Query.All<OperatorAuthority.MlOperatorWithPassiveAccount>().Any(ml => ml.Owner == authority && ml.Linked == passiveAccount));
}

And the last one:

using (var tr = s.OpenTransaction())
{
    var entityId = Guid.NewGuid();
    var id = Guid.NewGuid();
    var dic = new Dictionary<string, string> { { "1", "2" } };

    var keys = dic.Keys.ToArray();
    var fields2 = from f in Session.Current.Query.All<DocEntityField>()
                   join of in keys on f.SysName equals of
                   join r in Session.Current.Query.All<RegOverridenField>() on
                       new { Id = id, ForeignEntity = entityId } equals
                       new { r.EntityItem.Id, r.EntityItem.ForeignEntity }
                   where f.Entity.Id == entityId && r.Field == f
                   select f;

    Assert.DoesNotThrow(() => fields2.ToArray());

    var fields = from f in Session.Current.Query.All<DocEntityField>()
                 join of in dic.Keys on f.SysName equals of
                 join r in Session.Current.Query.All<RegOverridenField>() on new GeneralLink(id, entityId) equals r.EntityItem
                 where f.Entity.Id == entityId && r.Field == f
                 select f;

    Assert.DoesNotThrow(() => fields.ToArray());

    tr.Complete();
}

asked Aug 30 '11 at 09:59

xumix's gravatar image

xumix
425757682

Thanks, will check.

(Sep 01 '11 at 04:09) Dmitri Maximov Dmitri%20Maximov's gravatar image

Is this checked?

(Sep 17 '12 at 03:37) xumix xumix's gravatar image
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA