Coder Social home page Coder Social logo

dappermapper's Introduction

Install the package

  Install-Package DapperMapper

  https://www.nuget.org/packages/DapperMapper

Tools

DapperMapper will ease your Data Management in Microsoft SQL SERVER and and Sqlite with the same interface. We provide Bulkinsert from JSON file in the package named "JSONAM" ease as one line of code to insert millions record to the supported database.

JSONAM

  1. Set your connection
  // you can disregard App.Config and set the connection string on your program
  ConnectionManager.Set(ConnectionManager.ConnectionType.UserConfig, "#YOURCONNECTIONSTRING");
  // you can set the data base provider [Default set on MSSQLServer]
  ConnectionManager.Set(ConnectionManager.ConnectionType.UserConfig, "#YOURCONNECTIONSTRING",ConnectionManager.Provider.SqlClient);
  ConnectionManager.Set(ConnectionManager.ConnectionType.UserConfig, "#YOURCONNECTIONSTRING",ConnectionManager.Provider.Sqlite);
  1. Start your Bulk insert
	Jsonam j = new Jsonam();
	await j.InsertToSqlAsync(TableName: "Person", path: "People.json",DuplicateCheckingColumn:  "pid");

DapperMapper

  1. Create Connection String named "Repositoryconn":
  <connectionStrings>
    <add name="Repositoryconn" connectionString="#YOUR CONNECTIONSTRING#"/>
  </connectionStrings>
  // you can disregard App.Config and set the connection string on your program
  ConnectionManager.Set(ConnectionManager.ConnectionType.UserConfig, "#YOURCONNECTIONSTRING");
  // you can set the data base provider [Default set on MSSQLServer]
  ConnectionManager.Set(ConnectionManager.ConnectionType.UserConfig, "#YOURCONNECTIONSTRING",ConnectionManager.Provider.SqlClient);
  ConnectionManager.Set(ConnectionManager.ConnectionType.UserConfig, "#YOURCONNECTIONSTRING",ConnectionManager.Provider.Sqlite);
  1. Create Your Model
  public class User
    {
        [Key(true)]
        public long ID { get; set; }
        public string UserName { get; set; }
        public string Name { get; set; }
        public string Family { get; set; }
        public string Password { get; set; }
        public string Email { get; set; }
    }
  1. Map your Model
  DataMapper<User> usermap= new DataMapper<User>(nameof(User));
  1. Data Management ability after mapping
  User user = new User();
  usermap.Insert(user);
  Usermap.Update(user);
  Usermap.Delete(user);
  // Create the table
  // detect the type of sql based on SqlServer Data Type Mapping
  // https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings
  Usermap.Create();
  
  Usermap.Count();
  Usermap.FindByID(1);
  IEnumerable<User> result = Usermap.SearchBy(s=>s.Name.Contains("John"));
  IEnumerable<User> result2 =Usermap.SearchBy(s=>s.Name.Contains("John") && s.Family == "Doe");
  IEnumerable<User> all = Usermap.GetAll();
  
  1. Open Sql Query
  var result = OpenSql<dynamic>.DynamicExecute("Select top(1) Name + ' ' + Family as FullName from User");
  Console.Write(result[0].FullName);

dappermapper's People

Contributors

moasgh avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.