title: Where Query In One-One RelationShip in EF Repository Pattern
body: <p>Following is my database architecture, three entities:</p>
  
  <p><strong>Load</strong></p>
  
  <ul>
  <li>ID_Load</li>
  <li>From</li>
  <li>To</li>
  <li>Bids[]</li>
  </ul>
  
  <p><strong>Bid</strong></p>
  
  <ul>
  <li>ID_Bid</li>
  <li>ID_Load</li>
  <li>Amount</li>
  <li>Load</li>
  <li>Order</li>
  </ul>
  
  <p><strong>Order</strong></p>
  
  <ul>
  <li>ID_Order</li>
  <li>Status</li>
  <li>Amount</li>
  <li>Bid</li>
  <li>Load</li>
  </ul>
  
  <p>Load and Bid : One to Many       -- Load can receive multiple Bids</p>
  
  <p>Order and Bid  : One to One      -- A single bid will be mapped with a order</p>
  
  <p>Order and Load : One to One      -- An order can have only one Bid</p>
  
  <p>As you can see above I don't have ID_Load or ID_Bid properties in the order Entity as EF generate these automatically in the database, so the properties for these two fields are not added in the Order Entity</p>
  
  <p>I am currenlty using Repository pattern with <strong>Code First</strong> in my project.</p>
  
  <p>Now I want to get the Order information by ID_Load/ID_Bid (as there is a one to one relationship of Bid-Order and Load-Order table)</p>
  
  <p>I don't want to run any SP or Select query in the application, but having issue while doing this.</p>
  
  <p>If I run SQL I will have to write following query:</p>
  
  <p>Select * from Order Where ID_Load = 123</p>
  
  <p>Or</p>
  
  <p>Select * from Order Where ID_Bid = 123</p>
  
  <p>What is the alternative of this in EF/Repository Patterns in such situations.</p>
  
  <p>Can anyone please help me with this.</p>
  
  <p>Thanks,</p>