angularjs - Convert int to Sting for Restful Service to Read value that is a varchar -
i need read value varchar
acadyear
in database. i'm using string acadyear
this
public tblcoursedata readcoursedatabyacadyear(string acadyear) { using (masterentities1 entities = new masterentities1()) { tblcoursedata cust = new tblcoursedata(); cust = entities.tblcoursedatas.find(acadyear); return cust; } })
interface
` `[webinvoke(method = "get", uritemplate = "/readcoursedatabyacadyear? academicyear={acadyear}", responseformat = webmessageformat.json)] [operationcontract] tblcoursedata readcoursedatabyacadyear(string acadyear);
js controller
function ctrlreadcoursedatabyacadyear($scope) { $scope.submit = function () { function myfunction() { location.reload(); } //make sure change host , port match url var query = "http://localhost:50491/restservice.svc/readcoursedatabyacadyear?"; query += "academicyear=" + $scope.academicyear; $.ajax({ url: query, crossdomain: true, datatype: 'json', type: 'get' }) .done(function (json) { $scope.customerid = json.customerid; $scope.academicyear = json.academicyear; $scope.subjectcode = json.subjectcode; $scope.coursenumber = json.coursenumber; $scope.coursetitle = json.coursetitle; $scope.semester = json.semester; $scope.courselevel = json.courselevel; $scope.creditvalue = json.creditvalue; $scope.academicgrade = json.academicgrade; $scope.$apply(); }) .fail(function () { alert("course id not exist!"); }); } }
angular / bootstrap view
<div class="col-lg-8"> <div class="panel panel-info"> <div class="panel-heading"> <h3 class="panel-title">search by</h3> </div> <form data-ng-submit="submit()" data-ng-controller="ctrlreadcoursedatabyacadyear"> <div class="form-group"> <!--data-ng-repeat="customer in customers"--> <label>seaarch by: </label> </br> <label> name</label> <div> <input maxlength="40" class="form-control" id="academicyear" placeholder="name" data-ng-model="academicyear"> </div> <table class="table table-condensed table-striped"> <thead> <tr> <th><strong>psu id </strong></th> <th><strong>name </strong></th> <th><strong>phone number </strong></th> <th><strong>email </strong></th> <th><strong>academic year </strong></th> <th><strong>subject code </strong></th> <th><strong>course number</strong></th> <th><strong>course title</strong></th> <th><strong>semester</strong></th> <th><strong>course level</strong></th> <th><strong>credit value</strong></th> <th><strong>academic grade</strong></th> </tr> </thead> <tbody> <tr> <td class="form-group"> <input maxlength="40" class="form-control" id="customerid" placeholder="id" data-ng-model="customerid" > </td> <td class="form-group"> <div> <input maxlength="40" class="form-control" id="" placeholder="name" data-ng-model="academicyear"> </div> </td> <td class="form-group"> <div> <input maxlength="40" class="form-control" id="" placeholder="phone number" data-ng-model="academicyear"> </div> </td> <td class="form-group"> <div> <input maxlength="40" class="form-control" id="" placeholder="email" data-ng-model="academicyear"> </div> </td> <td class="form-group"> <div> <input maxlength="40" class="form-control" id="" placeholder="academicyear" data-ng-model="academicyear"> </div> </td> <td class="form-group"> <div> <input type="text" maxlength="40" class="form-control" id="subjectcode" placeholder="subjectcode" data-ng-model="subjectcode"> </div> </td> <td class="form-group"> <div> <input type="text" maxlength="40" class="form-control" id="coursenumber" placeholder="coursenumber" data-ng-model="coursenumber"> </div> </td> <td class="form-group"> <div> <input type="text" maxlength="40" class="form-control" id="coursetitle" placeholder="coursetitle" data-ng-model="coursetitle"> </div> </td> <td class="form-group"> <div> <input type="text" maxlength="40" class="form-control" id="semester" placeholder="semester" data-ng-model="semester"> </div> </td> <td type="text" class="form-group" id="courselevel" data-ng-model="courselevel"> <div> <input maxlength="40" class="form-control" id="courselevel" placeholder="courselevel" data-ng-model="courselevel"> </div> </td> <td class="form-group"> <div> <input type="text" maxlength="40" class="form-control" id="creditvalue" placeholder="creditvalue" data-ng-model="creditvalue"> </div> </td> <td class="form-group"> <div> <input type="text" maxlength="40" class="form-control" id="academicgrade" placeholder="academicgrade" data-ng-model="academicgrade"> </div> </td> </tr> </tbody> </table> </div> <p><input type="submit" id="submit" value="submit" class="btn btn-outline-info" /></p> </form> </div> </div>
however, it's giving me error
system.argumentexception: 'the type of 1 of primary key values did not match type defined in entity. see inner exception details. inner exception entitysqlexception: argument types 'edm.int32' , 'edm.string' incompatible operation. near predicate, line 1, column 82.'
how can convert value data type values can read through restful view?
Comments
Post a Comment