Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Pass LINQ object form Biz Class
Message
From
06/07/2010 16:14:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/07/2010 14:13:24
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, United States
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01471528
Message ID:
01471589
Views:
29
>Thanks for all your help Viv so please stick with me a little longer.
>
>Your example works but I am concerned that this won't accomplish what I would like to do. I am trying to build n tier data classes that I can us. I am working on a small web project now so I will use that as an example. I have my entity model setup against MS Sql server. I would like to setup a business class layer that holds the LINQ queries to access my data. In my web pages I would simply like to call the business layer to get the data object to populate the web page. Your example will do that. The next step I would like to post back the web page and save any changes. It looks to me like your example would break the ability to save the changes back. That means that I would have to send an object of the data from the page to the business class, then get the data from the EM model, update the EM object and the save. This seems like a kludge at best.
>
>All the examples that I can find show the LINQ code in the code behind of the web page. So is this even possible?
>
>a "Scatter,Gather Name " command would be really nice about now :).
>
>>The results in the debug window are the same. You can view them in the Debugger but, as before, you will not be able to access them in code - except as dynamic types as mentioned in my other post. If you need to access the collection outside the getDirectory() method then use a known class. e.g:
public class Address
>>    {
>>        public string Address1 { get; set; }
>>        //etc
>>    }
then:
public IEnumerable<Address> getDirectory()
>>        {
>>                       var queryobj = from dr in this.oEFobject.DIRECTORies
>>                       select new Address
>>                        {
>>                            Address1 = dr.ADDRESS1
>>                            //etc
>>                         };
>>          return queryobj;
>>        }
>>
>>

James,
If you want to return the query itself then do it as Viv suggested and create a type first and remove AsEnumetable() - if you want IQueryable. Normally you shouldn't use new but simply return dr. Or better yet get help from Albahari the Linq master:

http://www.albahari.com/nutshell/predicatebuilder.aspx

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform