Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:24:30+00:00 2026-06-09T00:24:30+00:00

Please consider following tables. Table: Document docID, docNr, docScanTime 10, 99, 2012-08-02 11, 98,

  • 0

Please consider following tables.

Table: Document

docID, docNr, docScanTime
10, 99, 2012-08-02
11, 98, 2012-08-02
12, 97, 2012-08-02
13, 96, 2012-08-02
14, 95, 2012-08-02

Table: DocumentFlag

userID, docID, isDelete, isArchive
41, 10, 1, NULL
42, 11, NULL, 1

There are five rows in Document table and two rows in DocumentFlag table. I am using following Linq statement to get a list of documents.

List<Document> docList = new List<Document>();
using (AppDataContext context = data.GetDataContext())
{
  docList = (from d in context.Documents
             join f in context.DocumentFlags on d.docID equals f.docID
             where f.usrID == userID
             select new Document
             {
                 DocID = d.docID,
                 DocNr = d.docNr,
                 ScanTime = d.docScanTime.Value,
                 UserID = f.userID,
                 IsDelete = f.isDelete.Value,
                 IsArchive = f.isArchive.Value,
              }).ToList<Document>();
}

public class Document
{
  public int DocID {get; set;}
  public int DocNr {get; set;}
  public DateTime DocScanTime {get; set;}
  public int UserID {get; set;}
  public byte IsDelete {get; set;}
  public byte IsArchive {get; set;}
}

But the problem is that I get only two rows that are in DocumentFlag. I want to get all rows in Document with information in DocumentFlag in the list. If DocumentFlag does not contain information about the document then it can store null in isDelete or isArchive.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:24:32+00:00Added an answer on June 9, 2026 at 12:24 am

    What you’re attempting is a LEFT OUTER JOIN in LINQ.

    Try this:

    using (AppDataContext context = data.GetDataContext())
    {
        docList = (from d in context.Documents
                    join f in context.DocumentFlags on d.docID equals f.docID into flg
                    where f.usrID == userID 
                    from fff in flg.DefaultIfEmpty()
                    select new Document
                    {
                        DocID = d.docID,
                        DocNr = d.docNr,
                        ScanTime = d.docScanTime.Value,
                        UserID = fff.userID,
                        IsDelete = fff.isDelete.Value,
                        IsArchive = fff.isArchive.Value,
                    }).ToList<Document>();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider the following scripts. Create Table: IF OBJECT_ID('Colortable') IS NOT NULL DROP TABLE
Please consider following schema CREATE table articles ( id Int UNSIGNED NOT NULL AUTO_INCREMENT,
Please consider following sample table structure: +-------------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null |
Please consider the following tweets table: tweet_id user_id text ---------------------------- 1 1 lorem ipsum
Please consider the following SQL Server table and stored procedure. create table customers(cusnum int,
Please consider the following table (created using a corresponding entity) request ------- id requestor
Please consider the following HTML: <td> Some Text <table>.....</table> </td> I need to manipulate
Consider the following database tables: Table messages with 13,000,000 rows (one row per message).
Please Consider the following table : As you can see the Name column has
Please consider the following table structure on Oracle: create table DOCS ( DOC_NO NUMBER

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.