Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A LINQ lookup dilemma
Message
From
01/07/2008 14:30:41
 
 
To
01/07/2008 10:37:50
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01327573
Message ID:
01327997
Views:
7
Hi,

I don't see where your JobItems collection is pulling data from more than one table.
Also I don't see any attributes in the JobItemsUI class definition...
Isn't it just a question of designing JobItemsUI so that 'DataContext.GetTable' works?

Are we talking at cross-purposes?
Regards,
Viv

>I've got all the attributes and Associations in place. I used the Linq-to-Sql designer and it's all working fine. There are some challenges though when working with normalized data. The easy linq queries work fine as long as you pull the full and pure object class that is defined in your dbml when you build your linq clause like this:
>
>
>                IEnumerable<JobItems> JobItems = from a in db.JobItems
>                                                   where a.job_num == JobNo
>                                                   orderby a.item
>                                                   select a
>                return JobItems;
>
>
>However, a challenge is created when you wish to create a view of a recordset that pulls columns from different tables to de-normalize the data. At that instance, in order to pass the collection around in code, you cannot use the demo-friendly anonymous types; rather, you have to model-up your own classes to hold the results, so you will be working with a typed data collection.
>
>
>              IEnumerable<JobItemsUI> JobItems = from a in db.JobItems
>                                                   where a.job_num == JobNo
>                                                   orderby a.item
>                                                   select new JobItemsUI(a.qty, a.part_no, a.dwg_no, a.Part.desc,a.price);
>                return JobItems;
>
>
>The class:
>
>   public class JobItemsUI
>    /// This is a custom class used to represent a UI displayable JobItem collection
>    {
>        public decimal qty { get; set; }
>        public string part_no { get; set; }
>        public string dwg_no { get; set; }
>        public string desc { get; set; }
>        public decimal price { get; set; }
>
>        public JobItemsUI(decimal Qty, string PartNo, string DwgNo, string Desc, decimal Price)
>        {
>            qty = Qty;
>            part_no = PartNo;
>            dwg_no = DwgNo;
>            desc = Desc;
>            price = Price;
>        }
>    }
>
>
>
>
>
>>Hi,
>>I'm only going from what I've read but isn't the first step to use attributes to map your JobItemsUI class to the underlying table and fields. I don't know if the created JobItemsUI objects will be automatically attached to the datacontext but if not it should be possible to do that in code.
>>Regards,
>>Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform