views:

156

answers:

1

Hi,

I Have Database that contains 4 tables

 TABLE TBLCARTITEM (CART_ID, ITEM_ID, PROMOTION_ID, many more cart item fields)
 TABLE XREFCARTITEMPROMOTION (CART_ID, ITEM_ID, PROMOTION_ID)
 TABLE TBLPROMOTION (PROMOTION_ID, PROMOTION_TYPE_ID, many more promotion fields)
 TABLE LKPROMOTIONTYPE (PROMOTION_TYPE_ID, PROMOTION_TYPE_DESCRIPTION)

The XREFCARTIEMPROMOTION table is a cross reference table that creates a many-to-many relationship between TBLCARTITEM and TBLPROMOTION.

TBLPROMOTION is linked to LKPROMOTIONTYPE by PROMOTION TYPE ID.

I am trying to use LINQ to get all of a particular carts items and related promotions.

So far i have everything with the exception of the LKPROMOTIONTYPE table.

using (WSE db = new WSE())
{ 
   var cartItems = db.XREFCARTITEM.Include("TBLPROMOTION")
           .FirstOrDefault(x => x.CART_ID == cartId);
}

This gives me everything for the cart including the promotions tied to each item. However when i go and try to include the LKPROMOTIONTYPE table i get the following run-time error:

A specified Include path is not valid. The EntityType 'Model.XREFCARTITEM' does not declare a navigation property with the name 'LKPROMOTIONTYPE'.

My question is: Does anyone know of a way to relate LKPROMOTIONTYPE to this cartItems object above?

Thanks.

+1  A: 

Answered my own question this time: var cartItems = db.XREFCARTITEM.Include("TBLPROMOTION.LKPROMOTIONTYPE").FirstorDefault(x => x.Cart_ID == cardId);

Billy Logan