vbdotnet.it

Tricks & tips, workaround, forum and ideas with .Net

About the author

Enrico Rossini è il gestore di questo blog.
E-mail me Send mail

Recent posts

Recent comments

Contributi

Best 6 ~ 6 users ~ 6 comments

Info legali

Le opinioni espresse in questo blog sono strettamente personali e ogni persona è responsabile dei commenti che inserisce. I marchi citati sono delle rispettive aziende.

© Copyright 2010

Advertising


Group by multipli e alias ai campi

Titolo quanto meno complesso. Partiamo da un esempio per spiegarmi meglio:

query = From a In eDao.MagazzinoArticoli Join m In eDao.MagazzinoMovimenti On a.IDArticolo Equals m.Articolo _
        Where m.Data <= tmp _
        Group By a.IDArticolo, a.CodArticolo, a.Descrizione, a.Fornitore, a.FornitoreCodice, a.PrezzoNetto1, a.UnitaMisura _
        Into car = Sum(m.QtaCaricata), scar = Sum(m.QtaScaricata), ret = Sum(m.QtaRettificata), imp = Sum(m.QtaImpegnata) _
        Select IDArticolo, CodArticolo, Descrizione, Fornitore, FornitoreCodice, QtaCaricata = car, QtaScaricata = scar, QtaRettificata = ret, _
               QtaImpegnato = imp, PrezzoNetto1, UnitaMisura

Esistono due tabella denominate MagazzinoArticoli (dove è presente la definizione degli articoli di un magazzino) e la tabella MagazzinoMovimenti (che raccoglie per ogni articoli i movimenti di carico e scarico). C'è il join tra le due tabelle e la condizione where sulla data del movimento. Il group by deve essere definito su tutti i campi su cui si esegue il raggruppamento. Dopo il comando Into si definisce una variabile alla quale dare il valore di un'oeprazione che nell'esempio è sempre un Sum.

Quando sono al select e devo specificare i campi, posso creare degli alias come se definissi una variabile. Attenzione: non è possibile riferirsi ai valori a ed m che identificano le due rispettive tabelle.

Ciao a presto!

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Monday, May 31, 2010 7:35 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Linq e uno o più Left Outer Join

Avendo perso anche tutto il pomeriggio della giornata di oggi a capire come fare in Linq un banale Left Outer Join, vi posto la query in Linq che ho realizzato.

qry = From f In eDoc.Fatture Where f.Data <= tmp Group Join pn In eDoc.PrimaNota On f.IDFattura Equals pn.FatturaID Into fv = _
      Group From p In fv.DefaultIfEmpty Join a In eDoc.Anagrafiche On f.Anagrafica Equals a.IDAnagrafica _
      Where f.Data <= tmp And (p.Data >= tmp Or p.Data Is Nothing) And (f.Annullata Is Nothing Or f.Annullata >= tmp) _
      Select a.IDAnagrafica, f.IDFattura, f.Numero, f.TipoDocumento, a.RagSoc, a.Nome, f.Data, f.Scadenza, f.TotaleImponibile, _
      f.TotaleDocumento, f.TotaleIVA, f.Anticipata, f.AnticipataImporto, f.AnticipataBanca, f.AnticipataData, f.AnticipataPercentuale, f.Riscossa, f.Annullata


Spero che vi sia utile!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: management | vb.net
Posted by enrico on Friday, May 21, 2010 8:55 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Come conoscere l'ID della scheda madre?

Questa funzione consente di conoscere l’identificativo del processore montato sul PC. Per poter eseguire correttamente questa funzione è necessario importare il namespace System.Management

   1:  Imports System.Management
   2:   
   3:  Public Function GetMotherBoardID() As String
   4:     Dim strMotherBoardID As String = String.Empty
   5:     Dim query As New SelectQuery("Win32_BaseBoard")
   6:     Dim search As New ManagementObjectSearcher(query)
   7:   
   8:     For Each info As ManagementObject In search.Get()
   9:        strMotherBoardID = info("SerialNumber").ToString()
  10:     Next
  11:   
  12:     Return strMotherBoardID
  13:  End Function

È possibile modificare questa funzione e trovare altre informazioni sul sistema.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Sunday, December 28, 2008 10:57 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Come conoscere l'ID del processore?

Questa funzione consente di conoscere l’identificativo del processore montato sul PC. Per poter eseguire correttamente questa funzione è necessario importare il namespace System.Management

   1:  Imports System.Management
   2:   
   3:  Public Function GetProcessorId() As String
   4:     Dim strProcessorId As String = String.Empty
   5:     Dim query As New SelectQuery("Win32_processor")
   6:     Dim search As New ManagementObjectSearcher(query)
   7:   
   8:     For Each info As ManagementObject In search.Get()
   9:        strProcessorId = info("processorId").ToString()
  10:     Next
  11:   
  12:     Return strProcessorId
  13:  End Function

Questa funzione può essere modificata per conoscere altre informazioni sulla macchina.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by enrico on Sunday, December 28, 2008 10:54 PM
Permalink | Comments (0) | Post RSSRSS comment feed