LLblgen: Select distinct?

≡放荡痞女 提交于 2019-12-13 14:05:05

问题


I can't seem to figure out how I can select only distinct entries in Llblgen 2.6 self-service model

I essentially want this query.

select distinct City
from peopleTable
where *predicates*

I've got my PeopleCollection and I'm not sure if there's a distinct method I can call or argument I can pass to GetMulti().


回答1:


Entities by definition cannot be distinct - even if they have the same value they are different rows in the same table.

You could use a TypedList or DynamicList to get a distinct list of city values - one of the parameters on the Fetch call is to get distinct items.

Or if you are using LINQ you could do

List<string> cities = PeopleCollection.Select(x=>x.City).Distinct();



回答2:


Adding a diff't answer to compliment Matt's, since I ended up here, but couldn't find a simple answer of how to do this anywhere, and you can't format code in a comment

ResultsetFields fields = new ResultsetFields(1);
fields.DefineField(PeopleFields.City, 0);

DataTable dynamicList = new DataTable();
adapter.FetchTypedList(fields, dynamicList, null, false);

foreach (DataRow row in dynamicList.Rows)
   Cities.Add(row[0] as string);

This gives a distinct list of all cities, filtering is done with an IRelationPredicateBucket instead of null to FetchTypedList.



来源:https://stackoverflow.com/questions/3189700/llblgen-select-distinct

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!