Click here to Skip to main content
15,559,491 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a linq complex query that is a join between 3 tables.
i obtain a complex type and at the end i would obtain a groupby of mulitple columns on a specific class.
my query is

C#
using (var cont = DALProvider.CreateEntityContext())
                {

                    var query =
                    from cliente in cont.T020_CLIENTI 
                    from sito
                    in cont.T021_SITI
                        .Where(s => s.ID_CLIENTE == cliente.ID_CLIENTE)
                        .DefaultIfEmpty()
                    from relStrumenti
                    in cont.T520_REL_STRUMENTI_SITI
                        .Where(s => s.ID_SITO == sito.ID_SITO)
                        .DefaultIfEmpty()
                   select new
                    {
                        clienteRec = cliente,
                        sitoRec = sito,
                        relStrumentiRec = relStrumenti
                    };
var vRes = (from clienteDef in query
                                
                                select new ClienteFiltrato
                                {
                                    RAGIONE_SOCIALE = clienteDef.clienteRec.RAGIONE_SOCIALE,
                                    ID_CLIENTE = clienteDef.clienteRec.ID_CLIENTE,
                                    COD_STRUMENTO = clienteDef.relStrumentiRec.COD_STUMENTO,
                                    DATA_DA = clienteDef.relStrumentiRec.DA_DATA,
                                    DATA_A = clienteDef.relStrumentiRec.A_DATA
                                }) ;




in vRes insert query result in a defined type ClienteFiltrato that is a class :

C#
public class ClienteFiltrato
    {
        public string RAGIONE_SOCIALE { get; set; }
        public decimal ID_CLIENTE { get; set; }
        public string COD_STRUMENTO { get; set; }
        public DateTime? DATA_DA { get; set; }
        public DateTime? DATA_A { get; set; }
    }


I have tried to do groupby before var vRes in this way:

C#
query=query.GroupBy(x => new { x.clienteRec.RAGIONE_SOCIALE, x.relStrumentiRec.DA_DATA, x.relStrumentiRec.A_DATA})
                        .Select(x=> x.FirstOrDefault());
                    var vRes = (from clienteDef in query//etc


but give me oracle erros because use APPLY and i haven't oracle 12.

so i don't know where i can do groupby to return mydata groupby RAGIONE_SOCIALE,DATA_DA,DATA_A

thanks a lot
Posted
Comments
Maciej Los 16-May-15 16:48pm    
Do not repost![^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900