本文整理汇总了C#中SimpleQuery.Join方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleQuery.Join方法的具体用法?C# SimpleQuery.Join怎么用?C# SimpleQuery.Join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleQuery
的用法示例。
在下文中一共展示了SimpleQuery.Join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResult
public virtual async Task<Paged<Entities.Url>> GetResult(Filter.Simple.Data.Filter filter, int? accountId = null)
{
filter.Resource = "Urls";
DataStrategy strategy = Database.Open();
var query = new SimpleQuery(strategy, filter.Resource);
var limit = _limit.Apply(filter);
var skip = _skip.Apply(filter);
dynamic accounts;
query = query.Join(ObjectReference.FromString("Accounts"), JoinType.Inner, out accounts)
.On(accounts.Id == new ObjectReference("AccountId", ObjectReference.FromString("Urls")))
.Select(
new ObjectReference("Id", ObjectReference.FromString("Urls")),
new ObjectReference("Address", ObjectReference.FromString("Urls")),
new ObjectReference("Id", ObjectReference.FromString("Accounts")).As("Account_Id"))
.Skip(_skip.Apply(filter))
.Take(_limit.Apply(filter));
if (accountId.HasValue)
{
var leftOperand = new ObjectReference("AccountId", ObjectReference.FromString("Urls"));
query.Where(new SimpleExpression(leftOperand, accountId, SimpleExpressionType.Equal));
}
if (filter.HasOrdering)
{
query = query.OrderBy(_order.Apply(filter), OrderByDirection.Ascending);
}
var data = await query.ToList<dynamic>();
var entities = AutoMapper.MapDynamic<Entities.Url>(data).ToList();
if (!entities.Any())
{
return null;
}
return new Paged<Entities.Url>
{
Limit = limit,
Skip = skip,
Data = entities
};
}
示例2: JoinShouldCreateExpression
public void JoinShouldCreateExpression()
{
dynamic q = new SimpleQuery(null, "foo");
q = q.Join(new ObjectReference("bar"), foo_id: new ObjectReference("id", new ObjectReference("foo")));
var query = (SimpleQuery) q;
Assert.AreEqual(1, query.Clauses.OfType<JoinClause>().Count());
var join = query.Clauses.OfType<JoinClause>().Single();
Assert.AreEqual("bar", join.Table.GetName());
}