c# - Nested Data Contract Exception in WCF - Cannot Implicitly convert Entity's model to model defined in DataContract -
c# - Nested Data Contract Exception in WCF - Cannot Implicitly convert Entity's model to model defined in DataContract -
problem statement:
in mvc 4 application,i have index view(list view) i'm bringing info multiple tables. i'm able bind info grid , fetch values.now i'm converting method involved in fetching info mvc controller wcf method,where i'm facing problems in conversion able controller code.following code have been using:
working code:
controller:
public actionresult index() { var result = getindexdata(); homecoming partialview(result); } public ienumerable<globalupgrademodel> getindexdata() { homecoming (from u in db.upgrade.asenumerable() bring together in db.asset.asenumerable() on u.id equals a.id a.assetid == u.assetid orderby u.assetid select new globalmodel() { assetmodel = a, upgrademodel = u }).distinct().tolist(); } public class globalmodel { public upgrademodel upgrademodel { get; set; } public assetmodel assetmodel { get; set; } }
here i'm able , bind info model view.everything working fine.
now have converted wcf:
iservice1.cs:
[operationcontract] [webinvoke(method = "get", uritemplate = "/getupgradeindexdata")] ienumerable<globalupgradedc> getupgradeindexdata(); [datacontract] public class upgradedc { [datamember] public int assetid { get; set; } [datamember] public long slno { get; set; } [datamember] public string upgradedetails{ get; set; } } [datacontract] public class assetdc { [datamember] public int assetid { get; set; } [datamember] public string assetdescrip { get; set; } } [datacontract] public class globalupgradedc { [datamember] public assetdc assetdc { get; set; } [datamember] public upgradedc upgradedc { get; set; } }
service1.svc:
public ienumerable<globalupgradedc> getupgradeindexdata() { homecoming (from u in dbentity.upgradedetails.asenumerable() bring together in dbentity.assettaggings.asenumerable() on u.tenantid equals a.tenantid a.assetid == u.assetid orderby u.assetid select new globalupgradedc() { assetdc = a, upgradedc = u //here i'm getting error cannot implicitly convert type entities model model of info contract }).tolist(); }
what i'm doing wrong?
c# asp.net-mvc entity-framework wcf
Comments
Post a Comment