Hi, create view in database. Then you can use them just like tables
using Linq or anyother data access layer.


Regards.



On Tue, Mar 31, 2009 at 8:20 PM, Stephen Russell <[email protected]> wrote:
>
> You will have to define the classes yourself.
>
> [DataContract(Name = "PeopleClass", Namespace =
> "http://schemas.lotmate.com/Tools/MSS/v1.0";)]
>    public class PeopleClass
>    {
>        [DataMember(Name = "ID", Order = 1, IsRequired = true)]
>        public Guid ID
>        {
>            get;
>            set;
>        }
>        [DataMember(Name = "Name", Order = 2, IsRequired = true)]
>        public String Name
>        {
>            get;
>            set;
>        }
>
>        [DataMember(Name = "ClubID", Order = 3, IsRequired = true)]
>        public Guid ClubID
>        {
>            get;
>            set;
>        }
>
>        [DataMember(Name = "Email", Order = 2, IsRequired = true)]
>        public String Email
>        {
>            get;
>            set;
>        }
>
>        [DataMember(Name = "Addr1", Order = 2, IsRequired = true)]
>        public String Addr1
>        {
>            get;
>            set;
>        }
> ------------Snip
>
> var myP = (from p in db.People
>                           join e in db.Support
>                           on p.ID equals e.PersonID
>                           where p.ID == peepID
>                           select new PeopleClass
>                           {
>                               ID = (Guid)p.ID,
>                               Addr1 = p.addr1,
>                               Addr2 = p.addr2,
>                               City = p.city,
>                               ClubID = (Guid)p.clubID,
>                               Email = p.email,
>                               Entry = (bool)p.entry,
>                               Judge = e.judgeStatus,
>                               Name = p.name,
>                               St = p.st,
>                               Steward = e.steward,
>                               Zip = p.zip
>                           }).First();
>                return myP;
>            }
> See how I put the PeopleClass as the container?
> I then fill it.
> …………………………………………………………………
> Stephen Russell –
> Senior Visual Studio Developer, DBA
>
> Memphis, TN
> 901.246-0159
>
>
>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of imad
>> Sent: Tuesday, March 31, 2009 1:04 AM
>> To: [email protected]
>> Subject: [DotNetDevelopment] Re: LINQ - create object from 2 tables
>>
>>
>> Have you created a relationship between your tables in SQL Server???
>>
>>
>>
>>
>> On Tue, Mar 31, 2009 at 4:55 PM, eddiec <[email protected]> wrote:
>> >
>> > Hi,
>> >
>> > I have added a SQL Server - LINQ item to my C# asp project and have
>> > created classes that correspond to the tables in my database.
>> >
>> > This has automatically created classes that map to the tables in the
>> > database. I can instantiate instances of the classes that map
>> directly
>> > to a table:
>> >            var Orders =
>> >                from c in context.Orders
>> >                where (c.OrderID.Equals(intCurrentOrder))
>> >                select c;
>> >
>> > Can someone please advise me how I can create an object / class where
>> > the class has attributes that are a join of two tables. (The Order
>> > object should contain Line Items. In the database the Orders table
>> and
>> > LineItems table has a 1:M join.)
>> >
>> > For example, I have classes Order and LineItem that have been created
>> > automatically through LINQ. Do I need to create a new Order class
>> that
>> > inherits from the Order class created automatically by LINQ and that
>> > contains an array LineItems?
>> >
>> > cheers,
>> >
>> > eddiec :-)
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com
>> Version: 8.0.238 / Virus Database: 270.11.31/2029 - Release Date:
>> 03/30/09 08:40:00
>
>
>

Reply via email to