1

I just don't understand what I have to set as the service name for the EntityManager.

I hava two controllers: an ApiController and a 'normal' controller:

API Controller:

[BreezeController]
public class TournamentApiController : ApiController
{
    private EFContextProvider<TournamentContext> _contextProvider;

    public TournamentApiController()
    {
        _contextProvider = new EFContextProvider<TournamentContext>();
    }

    [HttpGet]
    public string Metadata()
    {
        return _contextProvider.Metadata();
    }

    [HttpGet]
    public IQueryable<Tournament> Tournaments()
    {
        return _contextProvider.Context.Tournaments;
    }

    [HttpGet]
    public IQueryable<Team> Teams()
    {
        return _contextProvider.Context.Teams;
    }
}

'Normal' controller:

public class TournamentController : Controller
{
    public ActionResult Index()
    {
        return PartialView();
    }

    public ActionResult Details()
    {
        return PartialView();
    }
}

And in my DataSrvice.js file:

app.dataservice = (function (breeze) {

breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);

var serviceName = '/TournamentApi'; // What exactly do I need to set here? 

// *** Cross origin service example  ***
//var serviceName = 'http://todo.breezejs.com/breeze/todos'; // controller in different origin

var manager = new breeze.EntityManager(serviceName);
// manager.enableSaveQueuing(true);

var dataservice = {
    getAllTournaments: getAllTournaments,
};
return dataservice;

/*** implementation details ***/
function getAllTournaments() {
    var query = breeze.EntityQuery
            .from("Tournament");

    return manager.executeQuery(query);
}
})(breeze);

Can someone explain what is meant by a service name and thus, what I should use as the service name?

4

1 回答 1

0

serviceName 标识服务端点,即到 Web API 控制器的路由。这将是您用来与服务器通信的 URL 的“根”。因此,如果查询“团队”和“锦标赛”的实际端点是

 http://foo/bar/tournamentApp/teams ...
 http://foo/bar/tournamentApp/tournaments ...

那么您的服务名称将是

"foo/bar/tournamentApp"
于 2013-05-21T16:29:51.163 回答