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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:03:05+00:00 2026-06-01T11:03:05+00:00

I am trying to return a list of object from my mapper and save

  • 0

I am trying to return a list of object from my mapper and save them to my Entity Framework database.
My mapperclass looks like this

    class TimereportMappers
    {        
    public List<Days> dayMap(List<Day> days)
    {
        List<Days> output = new List<Days>();

        foreach (Common.Day input in days)
        {
            output.Add(new Days()
            {
                Date = input.Date,
                Hour = input.Hours
            });
            //output.Date = input.Date;
            //output.Hour = input.Hours;
        }

        return output;
    }

}

The problem in my dataaccess-class is that i dont know how to save the objects to my database, the method in dataaccess-class looks like this

     public void sendDays(List<Common.Day> days)
        {
            TimereportMappers mapper = new TimereportMappers();
            context.Days.AddObject(mapper.dayMap(days));         
            context.SaveChanges();
        }

But AddObject can only add 1 object? How do i add a list of objects?

Visual Studio gives me the errorcodes

Error 2 Argument 1: cannot convert from ‘System.Collections.Generic.List’ to ‘Timereport.BusinessLogic.Data_Access.Days’ C:\Users\widde\Documents\Visual Studio 2010\Projects\Timereport\Timereport.BusinessLogic\TimereportDataAccess.cs 43 37 Timereport.BusinessLogic

and

Error 1 The best overloaded method match for ‘System.Data.Objects.ObjectSet.AddObject(Timereport.BusinessLogic.Data_Access.Days)’ has some invalid arguments C:\Users\widde\Documents\Visual Studio 2010\Projects\Timereport\Timereport.BusinessLogic\TimereportDataAccess.cs 43 14 Timereport.BusinessLogic

  • 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-01T11:03:06+00:00Added an answer on June 1, 2026 at 11:03 am

    Would this work?
    (I can’t obvously test this but the idea is to only add 1 object instance at a time instead of the whole list)

    sendDays Method:

    public void sendDays(List<Common.Day> days)
    {
        TimereportMappers mapper = new TimereportMappers();
    
        foreach (var day in days)
        {
            context.Days.AddObject(mapper.dayMap(day));
        }
    
        context.SaveChanges();
    }
    

    TimereportMappers class:

    class TimereportMappers
    {
        public Days dayMap(Day input)
        {
            return new Days
            {
                Date = input.Date,
                Hour = input.Hours
            };
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to return a list of course id's from my database with PDO
I'm trying to remove a class object from list<boost::any> l l.remove(class_type); I tried writing
i am trying to return a list of users whose accounts have expired from
I'm trying to return a BL object from WCF server, but I get all
I'm working on a Spotify app and trying to create a views.List object from
I am trying to return List< T> from PowerShell function, but get one of:
Im trying to return a SimpleQuery list that queries a single table and uses
I am trying to use LINQ to return a list of tasks that are
I created an integer list and am trying to return the index of a
Trying to create a list to return some JSON data to a view. Following

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.