Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to create a datatable from the LINQ?
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Is it possible to create a datatable from the LINQ?
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01580581
Message ID:
01580581
Vues:
64
Hi everybody,

I am attempting the following LEFT JOIN LINQ query based on 2 datatables:
    var resultingQuery = from instructors in dtResources.AsEnumerable()
                                    join bookings in dtBookingInfo.AsEnumerable()
                                    on instructors.Field<String>("resource1") equals bookings.Field<String>("resource1")
                                    into AllInfo
                                    from bookings in AllInfo.DefaultIfEmpty()
                                    select new
                                    {
                                       resource1 = instructors.Field<String>("resource1")
                                    };

               return resultingQuery.CopyToDataTable<DataRow>();
The last line is wrong and doesn't compile and I can not get CopyToDataTable to show up in intellisense. I am wondering if there is any other way to move result of the query into a data table? Since I am creating a new anonymous type I suspect I am out of luck, right? The reason is I need to pass a data table to the method that generates my final result as a string.

In VFP this is the code I am trying to translate:
select I.instr_id as resource1, I.fname, I.lname, I.CheckedIn, ;
         b.booking_id, b.start_time, b.end_time, b.flex_tspan, ;
         b.layer, b.backcolor, b.forecolor, b.clip_sp, b.clip_loc, ;
         padr(space(iif(b.locked,2,0))+iif(empty(b.department+b.category+b.item), ;
         replicate('**'+alltrim(b.lsndescrip)+'** ',40), ;
         alltrim(b.modifiers)+' '+proper(alltrim(b.gst_name))+' '+alltrim(b.lsndescrip)+' '+ ;
         alltrim(str(b.booking_id,16))),200) as display_msg, 'PVT' as bartype, b.locked, ;
         iif(nvl(b.notelength,0)>0, .t., .f.) as isnotes;
         from csrInstr2 I;
         left outer join csrBookInfo b on I.instr_id==b.resource1 ;
         into cursor csrRetCursor ;
         order by &lcOrder
I found this blog post http://blogs.msdn.com/b/aconrad/archive/2007/09/07/science-project.aspx which is above my head :(
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform