本文整理汇总了C#中QueryFromClause类的典型用法代码示例。如果您正苦于以下问题:C# QueryFromClause类的具体用法?C# QueryFromClause怎么用?C# QueryFromClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueryFromClause类属于命名空间,在下文中一共展示了QueryFromClause类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitQueryFromClause
public override void VisitQueryFromClause(QueryFromClause queryFromClause)
{
base.VisitQueryFromClause(queryFromClause);
indexData.FromExpression = queryFromClause.Expression.Clone();
indexData.FromIdentifier = queryFromClause.Identifier;
indexData.NumberOfFromClauses++;
}
示例2: TryRemoveTransparentIdentifier
bool TryRemoveTransparentIdentifier(QueryExpression query, QueryFromClause fromClause, QueryExpression innerQuery)
{
if (!IsTransparentIdentifier(fromClause.Identifier))
return false;
Match match = selectTransparentIdentifierPattern.Match(innerQuery.Clauses.Last());
if (!match.Success)
return false;
QuerySelectClause selectClause = (QuerySelectClause)innerQuery.Clauses.Last();
NamedArgumentExpression nae1 = match.Get<NamedArgumentExpression>("nae1").Single();
NamedArgumentExpression nae2 = match.Get<NamedArgumentExpression>("nae2").Single();
if (nae1.Identifier != ((IdentifierExpression)nae1.Expression).Identifier)
return false;
IdentifierExpression nae2IdentExpr = nae2.Expression as IdentifierExpression;
if (nae2IdentExpr != null && nae2.Identifier == nae2IdentExpr.Identifier) {
// from * in (from x in ... select new { x = x, y = y }) ...
// =>
// from x in ... ...
fromClause.Remove();
selectClause.Remove();
// Move clauses from innerQuery to query
QueryClause insertionPos = null;
foreach (var clause in innerQuery.Clauses) {
query.Clauses.InsertAfter(insertionPos, insertionPos = clause.Detach());
}
} else {
// from * in (from x in ... select new { x = x, y = expr }) ...
// =>
// from x in ... let y = expr ...
fromClause.Remove();
selectClause.Remove();
// Move clauses from innerQuery to query
QueryClause insertionPos = null;
foreach (var clause in innerQuery.Clauses) {
query.Clauses.InsertAfter(insertionPos, insertionPos = clause.Detach());
}
query.Clauses.InsertAfter(insertionPos, new QueryLetClause { Identifier = nae2.Identifier, Expression = nae2.Expression.Detach() });
}
return true;
}
示例3: Visit
public override object Visit(Mono.CSharp.Linq.SelectMany selectMany)
{
var fromClause = new QueryFromClause();
fromClause.AddChild(new CSharpTokenNode(Convert(selectMany.Location), QueryFromClause.FromKeywordRole), QueryFromClause.FromKeywordRole);
if (selectMany.IdentifierType != null)
fromClause.AddChild(ConvertToType(selectMany.IdentifierType), Roles.Type);
fromClause.AddChild(Identifier.Create(selectMany.IntoVariable.Name, Convert(selectMany.IntoVariable.Location)), Roles.Identifier);
var location = LocationsBag.GetLocations(selectMany);
if (location != null)
fromClause.AddChild(new CSharpTokenNode(Convert(location [0]), QueryFromClause.InKeywordRole), QueryFromClause.InKeywordRole);
if (selectMany.Expr != null)
fromClause.AddChild((Expression)selectMany.Expr.Accept(this), Roles.Expression);
return fromClause;
}
示例4: TryRemoveTransparentIdentifier
bool TryRemoveTransparentIdentifier(QueryExpression query, QueryFromClause fromClause, QueryExpression innerQuery, string continuationIdentifier, out string transparentIdentifier)
{
transparentIdentifier = fromClause.Identifier;
Match match = selectTransparentIdentifierPattern.Match(innerQuery.Clauses.Last());
if (!match.Success)
return false;
QuerySelectClause selectClause = (QuerySelectClause)innerQuery.Clauses.Last();
Expression nae1 = match.Get<Expression>("nae1").SingleOrDefault();
string nae1Name = ExtractExpressionName(ref nae1);
if (nae1Name == null)
return false;
Expression nae2 = match.Get<Expression>("nae2").SingleOrDefault();
string nae2Name = ExtractExpressionName(ref nae2);
if (nae2Name == null)
return false;
bool introduceLetClause = true;
var nae1Identifier = nae1 as IdentifierExpression;
var nae2Identifier = nae2 as IdentifierExpression;
if (nae1Identifier != null && nae2Identifier != null && nae1Identifier.Identifier == nae1Name && nae2Identifier.Identifier == nae2Name) {
introduceLetClause = false;
}
if (nae1Name != continuationIdentifier) {
if (nae2Name == continuationIdentifier) {
//Members are in reversed order
string tempName = nae1Name;
Expression tempNae = nae1;
nae1Name = nae2Name;
nae1 = nae2;
nae2Name = tempName;
nae2 = tempNae;
} else {
return false;
}
}
if (introduceLetClause && innerQuery.Clauses.OfType<QueryFromClause>().Any(from => from.Identifier == nae2Name)) {
return false;
}
if (introduceLetClause && innerQuery.Clauses.OfType<QueryJoinClause>().Any(join => join.JoinIdentifier == nae2Name)) {
return false;
}
// from * in (from x in ... select new { x = x, y = expr }) ...
// =>
// from x in ... let y = expr ...
fromClause.Remove();
selectClause.Remove();
// Move clauses from innerQuery to query
QueryClause insertionPos = null;
foreach (var clause in innerQuery.Clauses) {
query.Clauses.InsertAfter(insertionPos, insertionPos = clause.Detach());
}
if (introduceLetClause) {
query.Clauses.InsertAfter(insertionPos, new QueryLetClause { Identifier = nae2Name, Expression = nae2.Detach() });
}
return true;
}
示例5: VisitQueryFromClause
public virtual void VisitQueryFromClause(QueryFromClause queryFromClause)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(queryFromClause);
}
}
示例6: VisitQueryFromClause
public StringBuilder VisitQueryFromClause(QueryFromClause queryFromClause, int data)
{
throw new SLSharpException("SL# does not understand LINQ.");
}
示例7: Visit
public override object Visit (Mono.CSharp.Linq.SelectMany queryStart)
{
var fromClause = new QueryFromClause ();
var location = LocationsBag.GetLocations (queryStart);
fromClause.AddChild (new CSharpTokenNode (Convert (queryStart.Location), "from".Length), QueryFromClause.FromKeywordRole);
if (queryStart.IdentifierType != null)
fromClause.AddChild (ConvertToType (queryStart.IdentifierType), QueryFromClause.Roles.Type);
fromClause.AddChild (new Identifier (queryStart.IntoVariable.Name, Convert (queryStart.IntoVariable.Location)), QueryFromClause.Roles.Identifier);
if (location != null)
fromClause.AddChild (new CSharpTokenNode (Convert (location [0]), "in".Length), QueryFromClause.InKeywordRole);
fromClause.AddChild ((Expression)queryStart.Expr.Accept (this), QueryFromClause.Roles.Expression);
return fromClause;
}
示例8: VisitQueryFromClause
public void VisitQueryFromClause(QueryFromClause queryFromClause)
{
throw new NotImplementedException();
}
示例9: TryRemoveTransparentIdentifier
bool TryRemoveTransparentIdentifier(QueryExpression query, QueryFromClause fromClause, QueryExpression innerQuery)
{
if (!IsTransparentIdentifier(fromClause.Identifier))
return false;
Match match = selectTransparentIdentifierPattern.Match(innerQuery.Clauses.Last());
if (!match.Success)
return false;
QuerySelectClause selectClause = (QuerySelectClause)innerQuery.Clauses.Last();
NamedExpression nae1 = match.Get<NamedExpression>("nae1").SingleOrDefault();
NamedExpression nae2 = match.Get<NamedExpression>("nae2").SingleOrDefault();
if (nae1 != null && nae1.Name != ((IdentifierExpression)nae1.Expression).Identifier)
return false;
Expression nae2Expr = match.Get<Expression>("nae2Expr").Single();
IdentifierExpression nae2IdentExpr = nae2Expr as IdentifierExpression;
if (nae2IdentExpr != null && (nae2 == null || nae2.Name == nae2IdentExpr.Identifier)) {
// from * in (from x in ... select new { x = x, y = y }) ...
// =>
// from x in ... ...
fromClause.Remove();
selectClause.Remove();
// Move clauses from innerQuery to query
QueryClause insertionPos = null;
foreach (var clause in innerQuery.Clauses) {
query.Clauses.InsertAfter(insertionPos, insertionPos = clause.Detach());
}
} else {
// from * in (from x in ... select new { x = x, y = expr }) ...
// =>
// from x in ... let y = expr ...
fromClause.Remove();
selectClause.Remove();
// Move clauses from innerQuery to query
QueryClause insertionPos = null;
foreach (var clause in innerQuery.Clauses) {
query.Clauses.InsertAfter(insertionPos, insertionPos = clause.Detach());
}
string ident;
if (nae2 != null)
ident = nae2.Name;
else if (nae2Expr is IdentifierExpression)
ident = ((IdentifierExpression)nae2Expr).Identifier;
else if (nae2Expr is MemberReferenceExpression)
ident = ((MemberReferenceExpression)nae2Expr).MemberName;
else
throw new InvalidOperationException("Could not infer name from initializer in AnonymousTypeCreateExpression");
query.Clauses.InsertAfter(insertionPos, new QueryLetClause { Identifier = ident, Expression = nae2Expr.Detach() });
}
return true;
}
示例10: VisitQueryFromClause
public override void VisitQueryFromClause(QueryFromClause queryFromClause)
{
ProcessName(queryFromClause.Identifier);
base.VisitQueryFromClause(queryFromClause);
}
示例11: VisitQueryFromClause
public override void VisitQueryFromClause(QueryFromClause queryFromClause)
{
FixClauseIndentation(queryFromClause, queryFromClause.FromKeyword);
}
示例12: TryRemoveTransparentIdentifier
bool TryRemoveTransparentIdentifier(QueryExpression query, QueryFromClause fromClause, QueryExpression innerQuery, out string transparentIdentifier)
{
transparentIdentifier = fromClause.Identifier;
Match match = selectTransparentIdentifierPattern.Match(innerQuery.Clauses.Last());
if (!match.Success)
return false;
QuerySelectClause selectClause = (QuerySelectClause)innerQuery.Clauses.Last();
Expression nae1 = match.Get<Expression>("nae1").SingleOrDefault();
string nae1Name = ExtractExpressionName(ref nae1);
if (nae1Name == null)
return false;
Expression nae2 = match.Get<Expression>("nae2").SingleOrDefault();
string nae2Name = ExtractExpressionName(ref nae2);
if (nae1Name == null)
return false;
// from * in (from x in ... select new { x = x, y = expr }) ...
// =>
// from x in ... let y = expr ...
fromClause.Remove();
selectClause.Remove();
// Move clauses from innerQuery to query
QueryClause insertionPos = null;
foreach (var clause in innerQuery.Clauses) {
query.Clauses.InsertAfter(insertionPos, insertionPos = clause.Detach());
}
query.Clauses.InsertAfter(insertionPos, new QueryLetClause { Identifier = nae2Name, Expression = nae2.Detach() });
return true;
}
示例13: VisitQueryFromClause
public virtual void VisitQueryFromClause(QueryFromClause queryFromClause)
{
VisitChildren (queryFromClause);
}
示例14: QueryFromClause
/* public override object Visit (Mono.CSharp.Linq.Query queryExpression)
{
var result = new QueryFromClause ();
var location = LocationsBag.GetLocations (queryExpression);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryFromClause.FromKeywordRole);
// TODO: select identifier
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryFromClause.InKeywordRole);
var query = queryExpression.Expr as Mono.CSharp.Linq.AQueryClause;
// if (query != null && query.Expr != null)
// result.AddChild ((AstNode)query.Expr.Accept (this), QueryFromClause.Roles.Expression);
return result;
} */
public override object Visit (Mono.CSharp.Linq.SelectMany selectMany)
{
var result = new QueryFromClause ();
// TODO:
// Mono.CSharp.Linq.Cast cast = selectMany.Expr as Mono.CSharp.Linq.Cast;
var location = LocationsBag.GetLocations (selectMany);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), "from".Length), QueryFromClause.FromKeywordRole);
// result.AddChild ((AstNode)cast.TypeExpr.Accept (this), QueryFromClause.Roles.ReturnType);
// if (cast != null)
// result.AddChild (new Identifier (selectMany.SelectIdentifier.Value, Convert (selectMany.SelectIdentifier.Location)), QueryFromClause.Roles.Identifier);
// result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), QueryFromClause.InKeywordRole);
// result.AddChild ((AstNode)(cast != null ? cast.Expr : selectMany.Expr).Accept (this), QueryFromClause.Roles.Expression);
return result;
}
示例15: VisitQueryFromClause
public void VisitQueryFromClause(QueryFromClause queryFromClause)
{
StartNode(queryFromClause);
WriteKeyword(QueryFromClause.FromKeywordRole);
queryFromClause.Type.AcceptVisitor(this);
Space();
queryFromClause.IdentifierToken.AcceptVisitor(this);
Space();
WriteKeyword(QueryFromClause.InKeywordRole);
Space();
queryFromClause.Expression.AcceptVisitor(this);
EndNode(queryFromClause);
}