wpf and ef select part of a table with include

I have a table with many fields and I want to get only a few individual fields, I work with EF and I add another table to the query as follows

            var Test= ve.Folders.Include("Hosting")
                .Where(a => a.Collateral!= true)
                .AsEnumerable()
                .Select(p => new 
                {
                    id = p.Folder_Id,
                    name = p.Full_Name,
                    add = p.Address,
                    date1 = p.Collateral_Date,
                    sName = p.Hosting._Name
                })
                .ToArray();

But with the field (sName= p.Hosting._Name) that is associated with the second table without any value query not working Many attempts have been tried but without result (interesting when I ask without Select everything works well)

Thanks in advance for any help

Answers


One thing to note is that, in this case, there's little benefit to the Select after the call to AsEnumerable, since all the data in the table is still queried from the database (not just the fields you specifiy).

If you want to avoid that, and only query those five fields, you can remove the AsEnumerable call. That means the Select will execute as part of the SQL query. This also means the Include is unnecessary, since the Select will query all of the data you want.

var Test= ve.Folders
            .Where(a => a.Collateral!= true)
            .Select(p => new 
            {
                id = p.Folder_Id,
                name = p.Full_Name,
                add = p.Address,
                date1 = p.Collateral_Date,
                sName = p.Hosting._Name
            })
            .ToArray();

Need Your Help

Google API - URL Shortener with R

r api curl rcurl

I'm attempting to use R to shorten a batch of URLs quickly. The google API documentation provides the solution below using curl

Facebook api message thread url framing

facebook facebook-graph-api facebook-c#-sdk

I want to frame url to open a message threads in facebook from my app.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.