Note that there are some explanatory texts on larger screens.

plurals
  1. POIOC's not being injected into the service
    primarykey
    data
    text
    <p>It was working then it suddenly stopped working. I must have did something. I'm calling my service from an MVC controller. I'm using NHibernate with a service runner I found in this <a href="https://stackoverflow.com/a/15534457/263457">SO answer</a> Service.Session and Service.RequestContext are null.</p> <pre><code>public class AppHost : AppHostBase { static ILog log; //Tell ServiceStack the name and where to find your web services public AppHost() : base("Play it Forward", typeof(GiveawayService).Assembly) { LogManager.LogFactory = new Log4NetFactory(); log = LogManager.GetLogger(typeof(AppHost)); // This is a singleton NHibernate session factory. Container.Register(SessionManager.SessionFactory); } public override void Configure(Container container) { SetConfig( new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, }, EnableFeatures = Feature.All.Remove(GetDisabledFeatures()), ServiceStackHandlerFactoryPath = "api" }); var appSettings = new AppSettings(); Plugins.Add( new AuthFeature( () =&gt; new SteamUserSession(), new IAuthProvider[] { new SteamOpenIdOAuthProvider(appSettings) })); Plugins.Add(new SessionFeature()); container.Register&lt;ICacheClient&gt;(c =&gt; new MemoryCacheClient()); // TODO: Implement Redis //container.Register&lt;ICacheClient&gt;(c =&gt; new BasicRedisClientManager()); container.RegisterAutoWired&lt;GiveawayService&gt;(); container.RegisterAutoWired&lt;UserService&gt;(); container.RegisterAutoWired&lt;SecureUserService&gt;(); container.RegisterAutoWired&lt;GamesService&gt;(); ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container)); ServiceStackController.CatchAllController = reqCtx =&gt; container.TryResolve&lt;HomeController&gt;(); log.InfoFormat("AppHost Configured: {0}", DateTime.Now); } public override IServiceRunner&lt;TRequest&gt; CreateServiceRunner&lt;TRequest&gt;(ActionContext actionContext) { return new BaseServiceRunner&lt;TRequest&gt;(this, actionContext); } } </code></pre> <p>This one of my services where I'm having the problem.</p> <pre><code>public object Get(FindClosedGiveaways request) { if (request.Take &gt; 50 || request.Take == null) { request.Take = 50; } if (request.StartIndex == null) { request.StartIndex = 0; } //return RequestContext.ToOptimizedResultUsingCache( // base.Cache, // cacheKey, // TimeSpan.FromMinutes(15), // () =&gt; // { var session = RequestContext.GetItem("session") as ISession; IQueryable&lt;Entities.Giveaway&gt; q = session.Query&lt;Entities.Giveaway&gt;() .Fetch(x =&gt; x.Giveable) .Fetch(x =&gt; x.User) .Fetch(x =&gt; x.Winner) .Where(x =&gt; x.EndDate &gt; DateTime.UtcNow.Subtract(new TimeSpan, 0, 0, 0))); if (request.UserSteamID != null) { q = q.Where(x =&gt; request.UserSteamID == x.User.SteamID); } else if (request.UserID != null) { q = q.Where(x =&gt; request.UserID == x.User.ID); } q = q.OrderByDescending(x =&gt; x.EndDate).Skip(request.StartIndex.Value).Take(request.Take.Value); List&lt;GiveawaySummary&gt; list = q.ConvertAll( x =&gt; { // If GiveawaySummary contains another class as a property, it var giv = x.TranslateTo&lt;GiveawaySummary&gt;(); giv.GifterUsername = x.User.Username; giv.GifterSteamID = x.User.SteamID; giv.WinnerUsername = x.Winner.Username; giv.WinnerSteamID = x.Winner.SteamID; if (x.Giveable.Type == "PiF.Entities.Subscription") { giv.Subscription = x.Giveable.TranslateTo&lt;Subscription&gt;(); } else { giv.App = x.Giveable.TranslateTo&lt;App&gt;(); } return giv; }); return list; //}); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload