Help on Dinstinct - Linq

Hi,
I wrote this code:

Private Function Carica() As IEnumerable(Of GCA)
        Return From lista In DatiBase _
                    Where lista.Field(Of String)(Colonna3) <> "" _
                    Order By lista.Field(Of String)
(Colonna2),lista.Field(Of String)(Colonna3) _
                    Select New GCA With {.AAAA= lista.Field(Of String)
(Colonna1), _
                                                    .BBBB= lista.Field
(Of String)(Colonna2), _
                                                    .CCCC= lista.Field
(Of String)(Colonna3) _
                                                    }
    End Function
It works fine but.... how can I change to get the list with distinct
rows for Colonna3
 (= GCA.CCCC)?

Thanks in advance!
Cheers,
BlackSun
0
BlackSun
1/12/2010 4:09:11 PM
dotnet.languages.vb 830 articles. 0 followers. Follow

5 Replies
653 Views

Similar Articles

[PageSpeed] 22

BlackSun wrote:

> Private Function Carica() As IEnumerable(Of GCA)
>         Return From lista In DatiBase _
>                     Where lista.Field(Of String)(Colonna3) <> "" _
>                     Order By lista.Field(Of String)
> (Colonna2),lista.Field(Of String)(Colonna3) _

                       Group By CCCC = lista.Field(Of String)(Colonna3) 
Into Group _

>                     Select New GCA With {.AAAA= Group.First().Field(Of String)
> (Colonna1), _
>                                                     .BBBB= Group.First().Field
> (Of String)(Colonna2), _
>                                                     .CCCC= Group.CCCC  _
>                                                     }
>     End Function
> It works fine but.... how can I change to get the list with distinct
> rows for Colonna3
>  (= GCA.CCCC)?

See the changes I made above. But that is pseudo code to suggest how to 
approach that, not tested code. You might need to post the exact 
definitions of your types like DatiBase if you can't get it to work.


-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
Martin
1/12/2010 5:07:04 PM
Hi,

thank you for you help!

Cheers,
BlackSun

On 12 Gen, 18:07, Martin Honnen <mahotr...@yahoo.de> wrote:
> BlackSun wrote:
> > Private Function Carica() As IEnumerable(Of GCA)
> > =A0 =A0 =A0 =A0 Return From lista In DatiBase _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Where lista.Field(Of String)(Co=
lonna3) <> "" _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Order By lista.Field(Of String)
> > (Colonna2),lista.Field(Of String)(Colonna3) _
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Group By CCCC =3D lista.Fi=
eld(Of String)(Colonna3)
> Into Group _
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Select New GCA With {.AAAA=3D G=
roup.First().Field(Of String)
> > (Colonna1), _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .BBBB=3D Group.First().Field
> > (Of String)(Colonna2), _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .CCCC=3D Group.CCCC =A0_
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> > =A0 =A0 End Function
> > It works fine but.... how can I change to get the list with distinct
> > rows for Colonna3
> > =A0(=3D GCA.CCCC)?
>
> See the changes I made above. But that is pseudo code to suggest how to
> approach that, not tested code. You might need to post the exact
> definitions of your types like DatiBase if you can't get it to work.
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen --- MVP XML
> =A0 =A0 =A0 =A0http://msmvps.com/blogs/martin_honnen/

0
BlackSun
1/13/2010 11:04:02 AM
Hi,
> > Private Function Carica() As IEnumerable(Of GCA)
> > =A0 =A0 =A0 =A0 Return From lista In DatiBase _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Where lista.Field(Of String)(Co=
lonna3) <> "" _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Order By lista.Field(Of String)
> > (Colonna2),lista.Field(Of String)(Colonna3) _
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Group By CCCC =3D lista.Fi=
eld(Of String)(Colonna3)
> Into Group _
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Select New GCA With {.AAAA=3D G=
roup.First().Field(Of String)
> > (Colonna1), _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .BBBB=3D Group.First().Field
> > (Of String)(Colonna2), _
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 .CCCC=3D Group.CCCC =A0_
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
> > =A0 =A0 End Function
> > It works fine but.... how can I change to get the list with distinct
> > rows for Colonna3
> > =A0(=3D GCA.CCCC)?
>
> See the changes I made above. But that is pseudo code to suggest how to
> approach that, not tested code. You might need to post the exact
> definitions of your types like DatiBase if you can't get it to work.

Thak you for your reply... I changed the code and now it works but I
have another question....
If I would like to have distinct rows not for Column3 but for Column2
and Column3 togheter?

Ex:

Column 2 | Column3
AAA        | A1A1     =3D> OK
AAA        | BBB      =3D> OK
AAA        | CCCC   =3D> OK
AAA        | BBB     =3D> NO
ADES      | A1A1    =3D> OK

Thak you in advance.

Cheers,
BlackSun
0
BlackSun
1/14/2010 9:30:56 PM
BlackSun wrote:

>>                        Group By CCCC = lista.Field(Of String)(Colonna3)
>> Into Group _


> Thak you for your reply... I changed the code and now it works but I
> have another question....
> If I would like to have distinct rows not for Column3 but for Column2
> and Column3 togheter?

You can have composite grouping keys so simply use e.g.
   Group By CCCC = lista.Field(Of String)(Column3), DDDD = 
lista.Field(Of String)(Column2) Into Group

-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/
0
Martin
1/15/2010 4:47:38 PM
Hi,
> You can have composite grouping keys so simply use e.g.
> =A0 =A0Group By CCCC =3D lista.Field(Of String)(Column3), DDDD =3D
> lista.Field(Of String)(Column2) Into Group

Thank you very much for your help and sorry for the late in answering!

Cheers,
BlackSun
0
BlackSun
1/17/2010 4:23:58 PM
Reply:

Similar Artilces:

Help with variables!!!
I need to take variables entered in an input box and use them in other procedures within the project. After many failed attempts, I have this, but it doesn't reset the variables with each instance. Any ideas? I tried Public variables but it said I couldn't use them with a Sub or Function. Public Sub filenames() Dim WeekNumber, RegionName, Month, WeekNumberBox, RegionNameBox, MonthBox WeekNumberBox = "Enter the fiscal two-digit week number" RegionNameBox = "Enter the first three letters of the region name" MonthBox = "Enter the first three lette...

Help setting up e-mail scanning on exchange 5.5
I have setup scanned e-mail on out xerox printer but everytime the person goes to send a scan to somones e-mail out our network it doesn't send. I need to setup some sort of relay but don't know how to do it. Any help would be great. Thanks. ...

XSD help
Hi all I have a config file like so <config> <optionSet1> <option index="1" name="Set 1 index 1"/> </optionSet1> <optionSet1> <option index="1" name="Set 2 index 2"/> </optionSet1> </config> optionSet1-index1 can only have set values 1, 3, 5, 7 How do I define XSD for optionSet2-index1 so that if optionSet1-index1 is in 1, 5 then it must be null if optionSet1-index1 == 3 then it must be A or B if optionSet1-index1 == 7 then it must be B, C or D Thank you very much! P...

outlook help issue
trying to do F1 or bring up help in microsoft outlook and it tries to do install and then asks for common files disk and a psdk-x86.msi file off of that disk. cannot find this disk or those files anywhere. Any help?? ...

Help! on filtering a report using a form & query
Hi. I've got a database with lookup fields. I have a form, a query and a report whose record source is the query. I want the user to select the lookup field from a drop down combo box And then run the query. If I change the query so the the criteria reads: [Forms]![frmCloseOutFilter]![txtCollection] and then run it, it will prompt me for the collection, I type a "3" and I get the desired results. It also works If I then run the report separately. But, If I try to run it from the form, I select my collection (It's a two column combo box, the first column has a width of 0...

Please help! Want to auto-close opened XML file
Greetings, I need some help with what seems to be a simple task but which, as usual, is impossible to do given the state of VBA's help files. I am looping through a series of XML files in a folder and want to convert/save them off to another folder in CSV (because we found Excel can do this). Inside my loop, I am doing the following to open the file: Workbooks.OpenXML Filename:=(inputDir + xmlFile), LoadOption:=xlXmlLoadImportToList That's fine and dandy but I don't really need the workbook to open like a real workbook -- I need it to open like in C++ or Java (i.e. open it int...

"Cannot complete installation of Live OneCare v1.5 BETA" HELP
I recently downloaded and installed the new version of Windows Live OneCare Beta v1.5. Everything went fine up until I restarted my computer and it booted back up. I constantly kept getting an error message saying that there was a problem with Automatic Updates and it needed to close. In my actions to take box it said I needed to "Complete the installation" by clicking the button "Complete installation". When I click it gives me this error message "OneCare cannot complete the installation at this time because of a problem connecting to the service. Please check...

Help for a beginner!.....PLEASE???
I have never used Excel, but I want to create a mail list merge for MS Word. It says I have to create the mail listing in Excel. Is there an "English" version as to how to do this? :o) Help, I need instructions for dummies! All I want is a simple mail file to transport to Word! Tricia, have a look here and see if it will help http://www.mvps.org/dmcritchie/excel/mailmerg.htm -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 97 & ...

Help please ! Excel is hanging and I need to stop
Is there a way of stopping Excel in the middle of something which has clearly caused it to 'hang', ie appear to be doing something for so long and not seeming as though it will ever stop. I've just lost a whole load of work which I had to crash out of. Terry --- Message posted from http://www.ExcelForum.com/ Hi sometimes CTRL+BREAK will help -- Regards Frank Kabel Frankfurt, Germany > Is there a way of stopping Excel in the middle of something which has > clearly caused it to 'hang', ie appear to be doing something for so > long and not seeming as though i...

Blue screen of death appears out of nowhere due to app error please help
*Hi* i was just browsing the web as many of us do,anyways an error pops up saying acgshccg.exe has stopped working. but the file names really long,its called "YYggwBB udXFzgnnQszxf" heres the problem signature: Problem signature: Problem Event Name: APPCRASH Application Name: acgshccg.exe Application Version: 1.3.0.5 Application Timestamp: 4b55c976 Fault Module Name: StackHash_fd00 Fault Module Version: 0.0.0.0 Fault Module Timestamp: 00000000 Exception Code: c0000005 Exception Offset: 92401cf8 OS Version: 6.0.6001.2.1.0.768.2 Locale...

Wrapped classes from ActiveX
How I can make source code from activeX components (with all properities,methods etc) in Visual Net 2002 or higher ?? In Visual C++ 6.0 they were generated by environment. Visual Net 2002 generate only headers for ActiveX components (without methods and properities) I tried with MSFlexgrid 6.0, MSDataGrid and ADODC controls -- Darth Marhev ...

Can we tell which cell an image is on?
The user is clicking on a button that says "HIDE" and when the user hits it.. it hides the row where the button exists. IS THERE A WAY I CAN DO THIS? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ Hi kenji4861, Are you talking about an image or a CommandButton? If it's a CommandButton, you can use code like this: Private Sub CommandButton1_Click() With CommandButton1.TopLeftCell.EntireRow .Hidden = Not .Hidden End With...

Please Help: Append New text to Old text already present in databa
Hi All, I have an excel form which populates access database. On the form Once we input a student Id in the form, we can input student records and also add comments, after making the changes we click "Submit" and the data goes in the databae. One field that I have on the form is "Comments" Textbox whereTA can insert their comments for any student. Here multiple TA's can comment for one student. The issue I want to resolve is. When a new TA inserts a comment, Old comments are deleted and replaced by the new comments. Is there a way to append new commen...

Problem with Excel Help
WIN XO HE, XL 2002 SP3 Hi, every time I hit F1 within Excel, I am getting the following error message: "The window name "langrep" passed to HH_GET_WIN_TYPE has not been specified." Any idea how to fix that? Tx, S I have no idea, but I'd start with: Help|Detect and Repair (or maybe reinstall excel/office) (I have no idea what "WIN XO HE" is either--winXP Home???) saturnin02 wrote: > > WIN XO HE, XL 2002 SP3 > Hi, every time I hit F1 within Excel, I am getting the following error > message: > "The window name "langrep" passed...

help in excel functions
i am learning excel now and i have this issue that i could not solve i . i have 2 columns :the first includes the names of some projects .th second includes the number of hours of each project.each project ro takes more than one row in the column hours.so i need to know how i ge the whole hours of a specific project "in details please" ...thank ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com Hi Ramis344, It is always helpful if you can paste some of your worksh...

help with IF THEN #7
What is the correct syntax to write a statement that, in english, does this If cell L4 = 0 Then delete cells K4 through M4 and shift the cells up Better yet can something be written that checks all L cells for the 0 value and if it finds 0 then deletes the adjacent K through M cells and shifts all cells up TIA ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ ...

help me please
i have a production data base and i have created a form with a sub from to enter daily prodution. the main form has employee info (name , id number ) which is from an employee table, the sub form connect to the main by employee to input info such as start time machine number hours of production and efficency ect. my problem is that i need to check on a daily to make shure all employees in formation was imputed. i have two ideas on what to do just dont know how. the first is to use the main employee form as a check list to some how after i iput all the infromation for that employee for that d...

email help!
how do i delete an account on my outlook express..please help, nothings working :( d p o p wrote: > how do i delete an account on my outlook express..please > help, nothings working :( This newsgroup is for support of Outlook 97, 98, 2000, 2002 & 2003 from the Office family for Windows PCs. For Outlook Express (OE) support try posting in one of these newsgroups: microsoft.public.inetexplorer.ie4.outlookexpress for OE 4.x microsoft.public.windows.inetexplorer.ie5.outlookexpress for OE 5.x microsoft.public.windows.inetexplorer.ie55.outlookexpress for OE 5.5x microsoft.public.windows...

I need help to find...
In fact I need an "excel brain" to help me for some calculations. I have in excel : DATE COUNTRY RATE1 RATE2 COL(A) COL(B) COL(C) COL(D) 3 GER 1.50 2.30 3 FRA 1.15 6.50 4 GER 1.20 6.00 4 GER2 1.40 5.50 4 IT1 1.80 3.60 6 IT2 3.50 2.11 7 POL 4.10 ...

declaration help please
a third party added some code to one of my apps and didn't dim anything. i'm not sure how to dim these variables. can someone help? a couple examples in the code: DDEChannel = Application.DDEInitiate(app:="RSLinx", topic:="T09113") DDEItem = "Xfer_Sched_New" 'Tag in CompactLogix DDEChannel = Application.DDEInitiate(app:="RSLinx", topic:="T09113") DDEItem = "Xfer_Schedule[" & Num_i & "],L1,C1" 'Schedule Tag in CompactLogix -- Gary Keramidas Excel 2003 Gary, ...

"Phantom" payee... need help troubleshooting
So I've been running Money 2004 for almost 3 years now and am trying to figure out this latest puzzle: A few days ago I was perusing my list of Payees and noticed that "Comcast" only had 1 transaction listed in it. (from 2005) I was stunned, since I pay those morons a foolish amount of money for cable TV every month. There should be tons of transactions listed. I made sure there weren't 2 payees called Comcast but there weren't. I then took a look at my checking account (from which I pay all my bills) and tried to find my last month's payment to Comcast....

Outlook 2003 doesn't shut down completely
I have Outlook 2003 running on WinXP 2002 Home Ed. I have a problem with Outlook 2003 still running in the background after I shut it down. The icon remains in the bottom right corner (where the time is located) and it still receives emails. I've tried to right click the icon but there is no option to further close it down (see pic). http://i111.photobucket.com/albums/n129/forum_pix/Untitled-1-7.jpg The other check I did was to look in Task Manager and it shows that Outlook is closed down, it doesn't appear in applications anymore. Any help would be greatly appreciated! If y...

Need Help to Create Query
I would like to know how to write SQL Statement to get the result below Name Item Ann Item1 Item2 Ben Item3 TB1 UserID Name 1 Ann 2 Ben TB2 ItemID UserID Item 1 1 Item1 2 1 Item2 3 2 Item3 if add 4 1 Item4 the result will become Name Item Ann Item1 Item2 Item4 Ben Item3 Any idea, I'm using MS Access Thanks You provided an example of how you want the results output ... but no idea where the data is coming FROM. "How" depends on "what". More info, please... Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: Th...

Need help with non-alterable sheet
We have a worksheet where I work that someone has tampered with and made it non-alterable. Only certain cells can even be clicked and most features have been greyed out altogether. The sheet was protected but the protection was not passworded and has been removed but that didn't do anything to help. What else, besides protection, could have a sheet locked like this? ...

HELP !!! I need advice !
Hi To All I need to implement the following configuration: Main Proccess(say Server) that implements interproccess communication with another Proccesses(say Clients). All the proccesses run in the same mashine. But the dialog betweeen proccesses extremely frequent. The Server sends data to the clients every 50-100 ms. So my question is: What type of the interprocces communication is better for my case (I mean with the minimal overhead and etc..) 1-> Via TCP/IP ? 2-> Via fire_event(DCOM) 3-> WM_COPYDATA 4-> shared memmory 5-> or something else. I prefer (2) but I don't k...