Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Linq Statement nicht AsEnumerable()/ Visual Studio/LINQ/MySQL

Empfohlene Antworten

Veröffentlicht

Hallo an alle

Ich habe ein tool in Visual Studio 08 erstellt das mithilfe LINQ

alle Users mit bestimmten Rechten aus mehreren My-SQL Datenbanken

ausliest. Da bin ich jedoch auf etwas gestossen das ich nicht verstehe.

	

totalUsers = (from u in db.Users

                          join ug in db.User2UserGroups on u.Userid equals ug.Iduser									             join ugs in db.UserGroups on ug.Idgroup equals ugs.Id

		join cg in db.UserGroup2Categories on ugs.Id equals cg.Idgroup

		where cg.Idright == 3

		select u).Distinct().Count();

Dieses LINQ Statement gibt den Wert 1 zurück, was aber nicht stimmt, ohne das ".Distinct()" gibt es 20 zurück, das stimmt. Nach längerem Suchen kamen wir dahinter das er mit ".Count()" etwas anderes oder falsch zählt aber warum? Mit Try & Error habe ich dan herausgefunden dass das Resultat stimmt wenn man AsEnumerable anfügt, also so:

select u).Distinct().AsEnumerable().Count();

Aber das Intellicense von Visual Studio gibt an das es auch ohne das Enumerable sei....

Also das Problem wäre eigentlich gelöst, aber es nimmt mich doch trotzdem noch Wunder an was das lag, vielleicht kann mir es jemand von euch erklären.

Gruss Fidi

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.