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

  • Home
  • SEARCH
  • 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 8730859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:06:30+00:00 2026-06-13T09:06:30+00:00

I am trying to use Npoco but running into some problems with FetchOneToMany I

  • 0

I am trying to use Npoco but running into some problems with FetchOneToMany

I have a sql statement that joins 2 tables together and I output all the columns.

   [TableName("TableA")]
    [PrimaryKey("Id")]
    public class TableA
    {
        public int Id { get; set; }
        public DateTime EffectiveDate { get; set; }
         public IList<TableB> TableBs { get; set; }
    }

    [TableName("TableB")]
    [PrimaryKey("TableBId")]
    public class TableB
    {
        public int TableBId { get; set; }
        public int SomeNumber { get; set; }
          public int Id { get; set; } // TableA id
    }


Func<TableA, object> func1 = (x) => x.Id;
            Func<TableB, object> func2 = (x) => x.Id;
  var test = RelationExtensions.FetchOneToMany<AdminFeeBandGroup, AdminFeeBand>(unitOfWork.Db, func1,func2,sql, 1,1,"10-18-2012","10-22-2012");

I am passing 4 parameters in my real query. I get a result back and TableBs property is filled and looks good. However EffectiveDate is not filled for some reason and is the default C# time.

What am I missing?

Edit

This is what I have as my query

SELECT     TableA.Id, TableA.EffectiveDate, TableB.TableBId, TableB.SomeNumber
FROM         TableA INNER JOIN
                      TableB ON TableA.Id = TableB.Id
WHERE     (TableA.EffectiveDate = @0)


Func<TableA, object> func1 = (x) => x.Id;
            Func<TableB, object> func2 = (x) => x.Id;
  var test = RelationExtensions.FetchOneToMany<AdminFeeBandGroup, AdminFeeBand>(unitOfWork.Db, func1,func2,sql, "10-18-2012");
  • 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-13T09:06:30+00:00Added an answer on June 13, 2026 at 9:06 am

    This is how it should work.

    var sql = "select a.*, b.* from tablea a 
        inner join tableb b on a.id = b.id 
        where EffectiveDate = @0"
    
    List<TableA> results = 
        db.FetchOneToMany<TableA,TableB>(x=>x.Id, sql, new DateTime(2012,10,18))
    

    You must ensure your columns are selected in the same order that the generic parameters are listed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying use Thread but i have some problem (I am beginner at
I am trying use gem tire to search in my application. I have tables
I'm trying to use git-p4 to clone perforce depot. I keep running into a
I'm trying use eco for client-side templating. I have multiple .eco templates that I'd
I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
Im trying use a Java annotation in a Groovy class but have trouble to
Hi I'm trying use a datepicker on a field I have. I'm trying to
I am trying use javascript regular expressions to do some matching and I found
I have been trying use the edit_post_link() function to contain an image. All of

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.