GithubHelp home page GithubHelp logo

alexander-87 / dapper.fluentcolumnmapping Goto Github PK

View Code? Open in Web Editor NEW
25.0 2.0 5.0 21 KB

Fluent Object-Column Mappings for use with Dapper

License: MIT License

C# 100.00%
dapper fluent-interface lambda-expressions dapper-extensions ado-net data-layer

dapper.fluentcolumnmapping's People

Contributors

alexander-87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dapper.fluentcolumnmapping's Issues

Output data not automatically mapping non-specified fields

I have a model class:

public class QueryResults
{
  public double Distance { get; set; }
  public string StreetLine1 { get; set; }
  public string StreetLine2 { get; set; }
  public string City { get; set; }
  public string State { get; set; }
}

In my data access layer, one of the methods maps some of the model's fields.

var mappings = new ColumnMappingCollection();

// Start defining the mappings between each property/column for a type
mappings.RegisterType<QueryResults>()
  .MapProperty(x => x.Distance).ToColumn("distance")
  .MapProperty(x => x.StreetLine1).ToColumn("street1")
  .MapProperty(x => x.StreetLine2).ToColumn("street2");

mappings.RegisterWithDapper();

string query = "SELECT distance, " +
  "sites.street1, " +
  "sites.street2,  " +
  "sites.city, " +
  "sites.state, " +
  "FROM mytable ";

// Execute my query using Dapper 
IEnumerable<QueryResults> results = connection.Query<QueryResults>(query);

The results returned by the query do not include the unmapped properties/fields. Specifically, the City and State fields do not get populated.

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.