c# - Entity framework with Web Api returning object -


Hello I am new to the structure of the organization. I am following the objects

  Public Partial Sector lr {public lr () {this.lr_history = new HashSet & lt; Lr_history & gt; (); this. Public = new hashet & lt; Person & gt; (); } Public int _id {get; Set; } The name of the public string {get; Set; } Public String Notes {get; Set; } Public virtual iconging & lt; Lr_history & gt; Lr_history {get; Set; } Public virtual iconging & lt; Person & gt; People {receive; Set; }  

I have a code in my Web API controller

  public class lrController: ApiController {Private CTM db = New CTM (); // GET API / ADL Public In InMenable & lt; LR & gt; Getlr () {One to DBCtext Return on activation db.lr.AsEnumerable (); }  

This is returning to the above method but I want to return my own object

  lr.id lr.name lr_history.description Lrh_history.rate  

Can anyone show me how to get this?

Create a new model:

  class HistoryModel {public int id {get receive; Set; } Public string name {get; Set; } Public string history description {get; Set; } Public string historyRate {get; Set; }}  

and return to:

  Public IEnumerable & lt; HistoryModel & gt; Getlr () {One of the DBCTX. Activation returns db.lr.AsEnumerable (). Select (x = & gt; new history model {id = x.id, name = x.name, history description = x.history.description, HistoryRate = X.history.rate}); }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -