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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:58:58+00:00 2026-06-11T03:58:58+00:00

So I got 2 databases, 1 SQLite file, which is updated every week (so

  • 0

So I got 2 databases, 1 SQLite file, which is updated every week (so I ll need to run this update once a week). And a SQLserver (but now using SQLfile just for localtesting etc). However I am looking for a easy way to copy all the data from the SQLite file to the SQLserver, there like 10 classes, and they exist in both databses, except the sqlite has no capitals at the start while the sqlserver does.

there is a person table in the sqlite with id, name and lastname. While on the SQLserver the table is called Person (with a capital) and the columns are Id Name and Lastname. The SQlite file is provided by a 3th party and I can t decide whatever they do. The SQLserver is made with Code First EF. (And I prefere to CamelCase it all).

Is there an easy way to copy all the data, I was looking for a property loop of the classes and then to lower for example.

ForEach(var person in SQLiteDB.persons)
{
    Person thenewperson = new Person();
    foreach (var prop in person.GetType().GetProperties())
    {
        // Here I get stuck I want something like
        if(thenewperson.Haspropertie.ToLower(prop.GetName.ToLower) // This is incorrect but I think you ll understand if we do a ToLower then we can get it to work. Since only capitals are the things that are different.
        {
           //Then we copy the data to "thenewperson"
        }

    }
    SQlserverDB.Persons.AddorUpdate(thenewperson) // Not totaly correct but you get the point.
} 

I am not sure or I am going the right direction, I have googled on how to loop over properties, but no luck on finding a good way of copying the data. I also got headache from trying to fix VS 2012 to work with SQLite, but the ADO.net doesn t seem to work so I had to install VS2010 again etc lol (running both now).

Hope someone has a good solution for this, if you got any more questions feel free to ask.

Edit: I forgot to mention it also has a navigation propertys. (Like PersonAbilitys). Which also need to be copied

  • 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-11T03:59:00+00:00Added an answer on June 11, 2026 at 3:59 am

    This should done what you are trying (not tested, maybe fails):

    foreach(var person in SQLiteDB.persons)
    {
        Person thenewperson = new Person();
        foreach (var prop in person.GetType().GetProperties())
        {
            var newPersonProp = thenewperson.GetType().GetProperties()
                                                      .FirstOrDefault(p => p.Name.ToLower() == prop.Name.ToLower());
    
            if (newPersonProp != null)
            {
                newPersonProp.SetValue(thenewperson, prop.GetValue(person, null), null);
            }
        }
        SQlserverDB.Persons.AddorUpdate(thenewperson); // Not totaly correct but you get the point.
    } 

    However, you can improve it by pre calculating the property mappings, so you don’t have to lookup it for every SQLiteDB.persons.

    var propertyMapping = new Dictionary<PropertyInfo, PropertyInfo>();
    var efPersonType = typeof(Person);
    var sqlitePersonType = typeof(SQLLitePerson);
    
    foreach (var prop in sqlitePersonType.GetProperties())
    {
        var efProp = efPersonType.GetProperties()
                                 .FirstOrDefault(p => p.Name.ToLower() == prop.Name.ToLower());
        if (efProp != null)
        {
            propertyMapping.Add(prop, efProp);
        }
    }
    
    foreach (var person in SQLiteDB.persons)
    {
        Person thenewperson = new Person();
        foreach (var i in propertyMapping)
        {
            i.Value.SetValue(thenewperson, i.Key.GetValue(person, null), null);
        }
        SQlserverDB.Persons.AddorUpdate(thenewperson);
    }
    

    You can also pick up an object mapper, e.g. AutoMapper. Then you can create custom conventions to make it work.

    If you have more complex entities then you should go with AutoMapper instead of rolling your own mapping solution to save yourself time: AutoMapper Wiki

    Btw the most straightforward way to do it is to create hand written mappings.

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

Sidebar

Related Questions

I've got an SQLite3 file which I'd like to parse using PHP, but I'd
I have a SQlite database file with records which comes with my app. I
I got this code snippet to copy a file database to a memory database.
I'm stuck on this problem here. I've got an application which reads out an
I've got this database taken from assets folder, but i can't open it in
I've got a Java project, which uses a small SQLite database. Now I want
I need to use Sqlite, but there's a problem with my syntax (well that's
Sorry about this question but i never worked with SQLite, and i gone through
Imagine I've got a database with lots of data, from which users can search.
I have a simple problem with XML got from database. Now, this XML can

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.