c# - Entity Framework - Calling A Stored Procedure Without Mapping -


i use database-first approach using entity framework (ef). i'm investigating different ways of calling stored procedures (stored procedures not tied entities) using ef. currently, i'm using approach found here using designer (in approach, import stored procedure, create function import , use complex type mapped object). don't because relies on bloated edmx file , causes merge conflicts in source control when 2 or more people perform procedure , check in code.

i found this post claims can call stored procedure , map plain old c# object (poco).

my question if want map poco stored procedure in ef not using designer approach, how aliases column names? example, let's call stored procedure , particular column named "customerid" , want property mapped named "id" instead of "customerid". how can without using designer approach?

something following should work:

[your db context].database.sqlquery<[your poco class]>("[name of stored proc] [comma separated parameters]", parameter1, parameter2, .....) 

here's example 1 of applications:

_context.database.sqlquery<library>("usp_paged_select_libraries @userid, @offset, @fetch",                    useridparameter, offsetparameter, fetchparameter); 

within poco mark properties with:

[column("[your alias here]")] 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -