문제

Is there a way to build the Select statement in parts? I am building a dynamic query by working through loops, which works well for the FROM / JOIN aspects, but can't make the Select work...

e.g. rather than this:

var results = query.Select(
    u1.FirstName.As("AssistantName"),
    u2.FirstName.As("LeadName")
);

something like this:

var select = new SelectBuilder();
select.Add(u1.FirstName.As("AssistantName"));
select.Add(u2.FirstName.As("LeadName"));
var results = query.Select(select);

Any guidance much appreciated!

도움이 되었습니까?

해결책

You can pass an IEnumerable<SimpleReference> to the Select method, for example:

var columns = new List<SimpleReference>();
columns.Add(u1.FirstName.As("AssistantName"));
columns.Add(u2.FirstName.As("LeadName"));
var results = query.Select(columns).ToList();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top