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 7976621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:57:25+00:00 2026-06-04T08:57:25+00:00

I have two tables Parent and Child. Both tables have a primary key MyDate

  • 0

I have two tables Parent and Child. Both tables have a primary key “MyDate” declared as DateTime in Sql Server. Both tables have a record where MyDate is set to “2011-12-01 00:00:00.000”, i.e., 1st December 2011.

In my Linq to SQL dbml (.Net 3.5) I have an automatically created association between the two tables, on the MyDate property. The DataContext uses a login to the database that has its Default language set to “British English” in SQL Server (2008). When I run the Linq query:

var query
  from parent in myDataContext.PARENTs
  select parent

I get back Parent records but not the linked Child records.

In SQL Profiler I have this trace:

-- network protocol: TCP/IP
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language British
set dateformat dmy
set datefirst 1
set transaction isolation level read committed
exec sp_executesql N'SELECT [t0].[MyDate] FROM [dbo].[CHILD] AS [t0]
WHERE ([t0].[MYDATE] = @p0)','@p0 datetime',@p0='2011-12-01 00:00:00'

This returns 0 records; I have checked it by running it directly in a query window, using the same (British) login. If I comment out the “set dateformat dmy” I still get 0 records. If I run it using a login that is not British, I get a record back. If I use ’01-12-2011 00:00:00′ as the date (e.g., UK date format) and the British login, I get a record back.

It seems to me that Linq is not using the correct date format when it creates the date string to use in its query. As it is using “set dateformat dmy”, why is it not using that format in the date string it generates?

Is there a relatively simple way to fix this? Thanks.

Edit: in my model the MyDate property on both Parent and Child has a Server Data Type of “DateTime NOT NULL”, and a Type of “DateTime (System.DateTime)”.

  • 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-04T08:57:26+00:00Added an answer on June 4, 2026 at 8:57 am

    Try eager loading

    LINQ to SQL: Lazy and Eager Loading Hiccups

    var query = (from parent in MyDataContext.Parents select parent)
                    .Including(childs => parent.Childs);
    

    or

    try out

    from parent in Parents select new
         {parent.Name, parent.Whatever,
         Childs =
             parent.Childs.where(c=>c.Date== parent.Date) };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in an MS SQL Server 2005 database, parent and child,
I have a table with two child tables. For each record in the parent
I have two tables, Parent and Child. The column Parent.favorite_child has a foreign key
I have two tables a parent and a child table. The child table has
I have two tables Loan(Parent Table) and Receipt(Child table)what i want to do is
I have two parent tables, BusinessGroup and SocialGroup, and one child table, Members. A
I have two tables with parent - child relationship: PARENT table with id as
I have two tables that represent parent/child nodes, their types, and their relationships: Table
Suppose I have two tables in a parent - child relationship. Let's call them
I have two tables, one parent and one child table. Child will have many

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.