« first day (2140 days earlier)      last day (2791 days later) » 

12:00 PM
And I get that fixed how? MainController CTOR?
 
Yes, take an IDataContext in the constructor
and assign it to that member
 
Okay.
Considering I was told earlier to get rid of the CTOR, thats why I didnt have it there.
But it is now.
Which, crashes it immediately.
 
who said that?
 
1 hour ago, by War
@Xariez remove that ctor move the classes, clean up the naming and rejig that query
 
@War wtf
OK, did you do what I said earlier to do with wiring up the dependency injection?
 
12:06 PM
I havent looked much up about it, but since I were rather direcetly told that interfaces are good to have, I've got that if it has anything to do with each other.
 
C4u
C# 7.0 isnt available without the new visual studio preview 4.
And the preview 4 is only available for the enterprise users.
Sucks.
 
@Xariez you don't need interfaces to do DI but it makes it so much more useful. It's not magic though, you have to tell the application what to do. The framework has to know how to get an instance of IDataContext to pass to the controller's constructor
 
Fair enough
But you got as good as my current situation on that gist except for the CTOR being added to the controller, so besides that im rather lost even although I feel like whatever fault I got lying behind isnt that "huge" of a error. Might be the complete opposite.
 
What?
That sentence just looks like a random jumble of words to me
 
You got my current situation in the gist that I pasted, the link. aka. gist.github.com/JohannesSundqvist/…
And, I've added the CTOR which you told me to do.
But since its still broken, theres something missing (obviously), and even although I got a slight idea of what I am doing, its nothing that I could come up with now that looks obviously wrong.
 
12:13 PM
OK, follow that the article I linked earlier says about configuring dependency injection
 
Looking at it right now
services.AddTransient<IDateTime, SystemDateTime>(); - This little line
 
OR to check that it's working you can just make the constructor parameterless and create a DataContext yourself in the controller, it's a little hacky but it proves that what you have is working
 
I get what IDateTime is, but whats SystemDateTime? What should it be changed to, that is?
 
no not actually that
it's an example
 
That I know, but if you follow what i linked earlier you'll see what my interface looks like, so I am guessing that IDateTime shoudl be changed to IDataContext, but what about the latter?
 
12:17 PM
DataContext
 
Right.
That it did not like apparently
 
Please be more specific
 
This is as specific as it gets
The type 'CustomerManager.Models.DataContext' cannot be used as type parameter 'TImplementation' in the generic type or method 'ServiceCollectionServiceExtensions.AddTransient<TService, TImplementation>(IServiceCollection)'. There is no implicit reference conversion from 'CustomerManager.Models.DataContext' to 'CustomerManager.Interfaces.IDataContext'.
 
pretty self-explanatory, that
 
The error message? Yes
The fix? Not so obvious to me anyways
 
12:20 PM
Implement the interface
DataContext is not an IDataContext
 
Well
So that means that this part needs to go in a file where the queries (DataContext) is not?
public DataContext(DbContextOptions<DataContext> options)
: base(options)
{
}
 
what?
no, it's nothing to do with the constructor
 
DataContext : DbContext is required for that part to work, but the Startup.cs part doesn't work on the other hand if I do it that way
 
None of this is anything to do with implementing the interface
Google "implement interface C#"
 
I got the interface, and I always have
 
12:25 PM
But it has nothing to do with your DataContext class
 
But since I got services.AddTransient<IDataContext, DataContext>(); , the DataContext class needs to look like public class DataContext : IDataContext {} or else I get the error message I just posted in chat.
 
yes!
exactly!
Implementing the interface, like I told you
 
But after I changed it to that, the constructor breaks, because it is expecting it to look like DataContext : DbContext {}
 
No
 
War
@scheien is that minecraft 2 or osmething
 
12:27 PM
The type 'CustomerManager.Models.DataContext' cannot be used as type parameter 'TContext' in the generic type or method 'DbContextOptions<TContext>'. There is no implicit reference conversion from 'CustomerManager.Models.DataContext' to 'Microsoft.EntityFrameworkCore.DbContext'.
Theres the exact message
 
Nobody said you had to remove the inheritance of DbContext
 
War
@Xariez gimme a sec to get up to speed again ... i've been working (like anyone believes that in here)
 
I think you need to read some more about C# and how to use the language
 
Oh fuck. SOrry about that.
Did NOT think that you can have multiple ones
But I'll still need to ask actually, SHOULD the DBContextOptions and queries be in the same class or in seperate?
Wether it works or not?
 
War
public User GetUser(int id)
{
    return Users.FirstOrDefault(u => u.Id == id);
}
try something like that @Xariez
 
12:30 PM
I don't recognise DbContextOptions, but it can't really be anywhere else, it's an argument to a DbContext
 
War
also ... you still don't need that ctor
 
@War god man don't confuse him any more, it's been a struggle just to undo whatever you told him earlier
 
Right @TomW
 
War
public class DataContext : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Customer> Customers { get; set; }
    }
how is that complex ?
oh is he trying to figure out the DI side ?
 
Not that changing that did too much of a difference as far as immediate-errors go
 
War
12:33 PM
DataContext is a concrete type that is self bindable ... or you can add the interface to it to create a rule for binding this to the interface
 
Putting queries in the context, eh, it's ok as designs go. For just getting it working it's not important
 
War
public class DataContext : DbContext, IDataContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Customer> Customers { get; set; }
    }
 
Thats what i got atm
plus the query that you just gave me as well - as good as
 
War
ok so then you need a rule in your DI container
 
Which I have said several times
 
War
12:34 PM
services.AddTransient<IDataContext, DataContext>(); ... it seems you already have
 
And linked to an article that explains how to do it
 
I do
 
War
@TomW sorry man ... im catching up
ok so whats the current problem @Xariez ?
 
InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[CustomerManager.Models.DataCon‌​text]' while attempting to activate 'CustomerManager.Models.DataContext'. - to be specific, on the other hand however I will have to leave for now, might hop into here later but yeah
 
War
so it knows the type but can't resolve it
seems odd
 
12:41 PM
You can lead a noob to documentation but you can't make him read...
5
 
War
ah is that the current problem?
 
Explains exactly how to DI an EF Core datacontext
linked it once already
referenced it again in the recent conversation
 
War
dam that makes that harder than how I do it
I use ninject though ... is this for the built in DI stuff
jeez thats a ton of work by comparison lol
 
err what?
It's one line
 
War
overriding onconfiguring
building an options object to construct the context
 
12:45 PM
whaat
 
War
factory patterns
 
no, I linked to the specific section that is relevant
services.AddDbContext<BloggingContext>(options => options.UseSqlite("Filename=./blog.db"));
obviously not sqlite in this case
 
War
but why?
 
why what?
 
War
12:46 PM
LMAO
services.AddDbContext<BloggingContext>(options => options.UseSqlite("Filename=./blog.db"));
seems overkill
concrete types are self bindable
no rule needed
serviceProvider.GetService<BloggingContext>(); <-- all the code needed
maybe microsoft did some weird stuff with it
or maybe ninject does some magic I just don't know about lol
lol i did not know you can await stuff that aint async / a task
funny but feels ultimately pointless
 
await TimeSpan.FromMinutes(15);
0.o
 
War
exactly ROFL
 
@RoelvanUden Its almost sad how true this is ^^
 
War
I was like ... ehmmm .... WHUT ?
 
await from url in urls select DownloadAsync(url);
No.
 
War
12:57 PM
LMAO
 
What the language needs is MORE THINGS
 
War
@TomW ALL the things!!!
I still don't get the reasoning behind adding tuples
are they basically not just dynamic objects?
 
@TomW oh no. ohh nooooo. please make it go away. trump can be president, just make it go awayyyyyyy
 
How about an AOP step that implements GetAwaiter for everything
 
War
@KendallFrey its almost like they want to piss everyone off
 
1:01 PM
 
So it's not visible in your codebase, but you can await every fucking thing and some 'genius' programmer writes unnecessary await code everywhere
 
seeing 2000 line method in legacy code
 
you know, that article reminds me of Haskell
where you can implement anything on any type
even built-in ones
 
@QuietNaN how about 8k + :P
 
@Proxy is it a whole project in one method? :)))
 
user47589
1:04 PM
but can haskell forge new relationships where none previously existed? that's what i want most out of a language.
 
War
@QuietNaN @Proxy meh ... lt me know when you hit 20k lines
 
@Amy oh you're gonna love Haskell
 
@QuietNaN sadly but nope, there are more then few functions with over 1k lines
 
War
the dev in question thought that was the very definition of procedural programming
 
manager wants to talk about very old project :)))
 
War
1:06 PM
rofl
 
hahah
 
that is an amazingly creepy gif
 
coding in vba
 
War
feels like it came out of a horror movie
 
rofl
bug reporting in my company
 
War
1:11 PM
@QuietNaN dude I'm so jealous .... you have monkeys!!! such an upgrade
 
monkeys rule the world
 
Monkeys!
 
user986408
when designing a multitenancy saas api ... would you guys provide all api calls and let the devs use it how they like - even if it means they could do harm if used wrong - OR - build the calls in a way that he can't really destroy anything (scoped)?

examples:
a) the dev could patch user X at any time via PATCH /user/:id
b) he has to first authenticate as a user and can only make calls specific to that user (so he can't touch user X)
 
I look at it like this:
- someone will always try to break it on purpose
 
build the calls in a way that he can't really destroy anything (scoped)
 
1:14 PM
@codepushr Scoped.
 
Authenticate, Authorize
 
Permission filters to the rescue.
 
You really have to code to defend against that person never mind any accidental but destructive use, which means scoped
Suppose two businesses in direct competition are both customers?
 
War
@codepushr option b
 
user986408
i mean, he would only destroy stuff in his own data anyway - all our clients will have their data separated (multitenancy) ...
 
1:15 PM
How happy would they be to learn that you let their competitor trash their data?
 
@TomW If it has 24TB, it matches my setup.
^ A little late.
 
War
@codepushr I tend to give people ultimate freedom within their permission scope ... so if they fuck up they only fuck up what they have access too not the whole system
 
user986408
@War that's my point
 
War
users do dumb shit
bu there's only so far you can go
 
user986408
i was asking my question not in general but under the premise that they already are scroped - like inside their scope - should i there guide them with my calls or give them complete freedom
 
War
1:17 PM
It's like my boss says adding the rule that users must reset their passwords once ever 30 days to anything makes it less secure on the basis that users are stupid will just write their ever changing passwords down
 
user986408
i'm new to this, i'm having a hard time explaining, sorry :D
 
War
my thinking is that the system is not less secure ... in fact it's more secure
can't defensively code a user
 
@codepushr Guide them. I presume you have an administrator permission that can basically fuck up a whole lot? Design your APIs around such power users so that chances are less that a fuckup occurs.
 
War
@codepushr i have a granular model that's basically both
 
user986408
i understand...
 
War
1:19 PM
I can grants extremely limited readonly permissions to one thing or full global admin rights and everything in between
basically have a model where virtually every field in every db is controlled by some sort of permission / business rule
then it's down to determining who can do what and when
 
That's painful
 
War
it's not actually as bad as you might think
the system is actually mostly convention based but we have the problem that 1 db is serving up data for multiple organisations across the planet
 
CMSes often work like that
 
War
without such permissions we could have a problem ... quite a serious one too
 
Sitecore does
 
1:20 PM
Which planet?
 
War
bad @TomW
 
item-level permissions on everything, where everything in the system is an item
 
War
shitecore ... pah
 
Which is why Sitecore is slow as shit
 
War
@TomW yeh it's essentially that kind of model we have though
 
1:21 PM
I can feel the love for sitecore
 
War
except ours aint slow as shit
 
*Shitecore
 
War
and aint building stupid ass blobs of xml and storing them in the db
 
those stupid ass blobs
 
War
dumbasses thought that was a good idea ... sheesh
 
1:22 PM
I'm guessing you don't particularly like sitecore huh
 
War
what used to gripe me most about shitecore was that it doesn't behave how they train people it should behave
indexing is an interesting one
they drive their search from a lucene index
 
That never worked, for us
 
War
the lucene index frequently has to be rebuilt
 
Search indexing would crash regularly and fill the logs with shit
 
War
and the search is basically useless without custom code to pull business intel from the "xml blobs in the sql side"
shitecore really pisses me off as products go ... i'm not a fan of sharepoint but give me that over shitecore any day
 
1:25 PM
An outside consultancy had built an absolutely crazy web forms MVP framework on top of it, which made it that much harder to work with
Shittiest bit of work AKQA ever did, which is a shame, because most of their stuff is amazing
 
War
jeez .. why anyone builds anything on shitecore is beyond me ... the overhead is no different to that of just employing a dev team to build you a custom app
and shitecore partners know even less about the system which means you often get even worse advice when something goes wrong
I'm shitecore qualified ... took the course ... but never want to use that training ever again
 
likewise
only the one day foundations thing
 
Deus Ex: Mankind Divided - Microtransactions in a Singleplayer
how nice
 
War
@TomW I did all the complex shit too ... something like 5 days worth
 
Well, pay for upgrades, sounds like it fits
 
War
1:31 PM
I already had a background in CMS systems though from previous job roles
 
Indeed
Oh well, had a pretty uplifting mailconversation with one of my main customers that today got the news that I am leaving
If only you could take customers with you ;p
 
(catching up) @TomW You can't make me read even although I read it and implemented it? Not all of it but the part that seemed relevant in the Startup.cs file. Still, continuing to catch up.
So @War , that "all the code needed" that you mentioned, you certain? I'll try adding it as soon as I drag it down from github but since the documents say otherwise.
 
War
@Xariez not absolutely certain ... however that is the case with Ninject
concrete types are self bindable so no need to create a binding rule for them
 
Also for the record, I had to drive home, thats why I had to go. Anyways, testing that now
 
War
no idea how the built in stuff from microsoft works though
with ninject you just put your conn string in config and define your context
then ask for it
ninject figures it all out for you without needing anything else
var db = kernel.Get<MyDbcontext>();
it just knows
 
1:39 PM
Hi Guys
 
Anyone here experience on Rest Web Service ?
 
War
@tHiNk_OuT_oF_bOx see star board item 1
none of us here have ever used the internet ... can't you tell
 
indexes on a table, any preference from BTREE to HASH?
 
Wait, im slightly confused
 
1:41 PM
@War
 
War
@tHiNk_OuT_oF_bOx
 
The docs say services.AddDbContext<BloggingContext>(options => options.UseSqlite("Filename=./blog.db")); , but thats not even slightly close to what you said was enough. Are we looking at two completely different things here? @War
 
War
@Xariez yes we are .... I'm just saying its requiring more effort to use what should be simpler because it's built in
 
Right
So in the case of serviceProvider.GetService<DataContext>(); , what should take "serviceProviders" place since thats giving me an error? Or should the whole thing be a variable?
 
War
@Xariez I don't ever make such a call so it's hard to say
I would do something like ...
 
user986408
1:45 PM
may i quickly introduce you into my current model to make my question clearer :D ?
 
War
public class FooController : Controller<Foo>
{
         public Foocontroller(IDataContext<Foo> fooContext) {  }
}
in my situation the correct data context would be figured out by IoC and injected in
I would never actually ask for the IoC object and then ask that for the context directly
 
Im guessing that third line is a CTOR?
 
War
that's considered to be the IoC / Service Locator anti pattern
@Xariez please tell me that's a joke right?
you must have seen a ctor before ?
 
I have
And I thought it looked odd to be a ctor
 
user47589
the C isn't capitalized, but that's all
 
War
1:48 PM
it's an empty one ... of course you would normally put some code it
 
user47589
there's nothing odd about it
 
War
yeh my bad on the typo
thx for the spot there amy
 
But at the end of the day, whats the easiest way out of this? For me thats not that experienced with C#? Just follow the docs mayhaps?
Like, to get the full context of things?
 
War
in the first instance yeh probably
whilst learning
safer / probably easier
 
oh god im so confused, lol
About all these arguements and what i actually should be looking at in this doc
 
War
1:53 PM
well ... you could take a look at ninject and see if that explains it any better
I think your problem is how to build your startup code
the controller and context are relatively trivial
but setting up something like IoC is a complex task at times
 
services.AddDbContext<DataContext>();
services.AddTransient<IDataContext, DataContext>();
services.AddApplicationInsightsTelemetry(Configuration);

services.AddMvc();
Thats the current content of the Startup.cs/ConfigureServices atleast
 
War
        public void Configuration(IAppBuilder app)
        {
            CreateKernel();
            Auth.Configure(app, kernel);

            cookieOptions = new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                LogoutPath = new PathString("/Account/Logout")
            };
            app.UseCookieAuthentication(cookieOptions);

            ControllerBuilder.Current.SetControllerFactory(kernel.Get<IControllerFactory>());
i use owin to setup my apps
        static void CreateKernel()
        {
            kernel = new StandardKernel();
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => kernel);

            // load convention based rules
            kernel.Bind(x => x.FromAssembliesMatching("Core.*.dll")
                .SelectAllClasses()
                .BindAllInterfaces()
            );

            // modules
            kernel.Load<ApplicationNinjectModule>();
        }
and thats my IoC code
 
Cool, nto that its saying me a lot, lol
 
War
from there I can just ask for stuff in ctors
I never pass the ninject kernel in to anything
only ever ask for things like your DataContext
hmmm that line shouldn't be there ... kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => kernel);
 
How does it cope with multiple implementations of an interface?
You have nothing there that tells the container how to choose
 
War
2:00 PM
I use modules to overide where applicable
e.g. IService<T> is handled by my core module (the code above is from my front end not the back end)
for that I bind the interface to a factory
then the factory decides what type of service to return
Rebind(typeof(IService<>)).ToMethod(ctx =>
{
    var provider = ctx.Kernel.Get(typeof(ServiceFactory<>).MakeGenericType(ctx.GenericArguments)) as IProvider;
    return provider.Create(ctx);
});
that's my service rule @TomW
so I can even use different types of factories based on the context of the question if need be
that would probably be overkill though
 
Man who thought sql would be fun ..
 
War
ninject has a built in rule that basically says for any given <T> you can only define 1 binding so it keeps things nice and simple
@ElieSaad what ya up to ?
 
@War creating some stored proc. Trying to combine 3 shits into one
And i am null with them :D
 
War
lol
 
Guys. What's the best way to store items in a database for a MMORPG? For every category (swords, staffs, potions, scrolls,..) a different table, or a more advanced approach? like: (item, category, property) example: item: id: 1, name: Visitor sword, price: 300, cat_id: 1. category: 1, Swords. property: id: 1, name: attack power. And then link everything.
 
War
2:08 PM
i'd create an item tbale and a category table
then link the rows
there would probably be some sort of bag table too ... so item would have something like a bagId on it
then as shit gets moved around you just set that
 
But how about the parameters like "attack damage" on an item
 
War
ah you want inheritance
 
Item: My sword, cat: Swords
Category: Swords
Parameter: Attack damage, cat: Swords.
ParameterValue: itemId, paramId
?
I don't know what I want, but I just want something that works properly. It doesn't have to be the easiest approach
 
War
probably make sense to have an abstract base or an interface then a table for each distinct item type
interface IItem {}
interface IWeapon : IItem {}
interface IArmour : IItem {}

public class Sword  : IWeapon {}
 
You might end up with conditions table, and so in. read the article
 
2:19 PM
@War Okay, but then you would save the weapons in the database, as I did in my example, or?
 
War
@ErwinOkken you can only save a concrete type ... so in my example thats 1 table that only stores swords
also read @ntohl's example above
 
I will read it. Thanks both !
 
Back. Just for the sakes of it @War , did you look at my latest git that you should have seen when you earlier said that you were catching up?
 
War
@Xariez i think so ... there's been a lot of links though
 
Because either way, what is actually required for this stuff to start working? Or is DI the faulty link atm?
 
War
2:24 PM
I think for the controller and Context code that's about as complex as it needs to be ... you're pretty much done
the issue seems to be startup unless I missed something
 
And the final answer for the CTOR on the main controller?
Keep or remove?
 
War
I used ctors to pass in dependencies
you'll probably need that to pass in your context
 
Right.
 
War
public YourController(DataContext db) { ... }
 
Yeah
Also, i just realised that since im on another computer right now than earlier today, i am getting issues with the path that its searching in for the config files <.<
Nvm now it worked
 
War
2:26 PM
if your IoC is setup right then it should all just magically happen
 
All of a sudden
services.AddDbContext<BloggingContext>(options => options.UseSqlite("Filename=./blog.db"));
This line, what the hell do I do with that Filename part if the database is on a remote server?
 
Are you using sqlite?
 
Well right now I am not, adding it isnt impossible
Or is it possible to run a .UseModel instead of .UseSqlite? Is that how it works?
 
Don't know, and documentation is not the easiest to find for this part
.UseSqlServer looks plausible
 
Well it accepts it
Oh and that wants a connectionString? Interesting
InvalidOperationException: The entity type 'CustomerManager.Models.Customer' requires a key to be defined.
This just gets more and more interesting
 
War
2:32 PM
@Xariez no idea in my case I just put the connection string in config (belongs there really as opposed to in code
 
Yeah, thats what I would want to do to
 
War
like I said before I think this example is a little convoluted and makes something dead simple a bit harder
 
But do I not need to do the .AddDbContext(); either way in Startup?
 
War
if you put the connection string in to config and give it the same name as the context type "DataContext" then you should be able to use the default ctor
The bit i'm not sure about is how this Microsoft stuff works
as I said before ... ninject is my go to ... I find it easier to work with
 
Thats what I am doing though, the connection name is DataContext, and the context type name is DataContext
But yes, like you're saying, I too feel like this is a lot harder than it should be, for such a common thing as a DB connection
 
2:40 PM
creating a test app in windows forms.
i created a tab page: add customer
in which i had put some textboxes and their respected labels and 'save button
then i coded and it was working fine, all of it.
But, then i added a groupbox within the tab 'add customer' and cut pasted my 'add customer' tab controls into that groupbox. Since then all the code i have written down nothing works. Why?
i tried cut pasting the controls back to the 'addcustomer' tab page out from the group box, but still no business logic behind it is working
 
Is there an easy way to bind an enum to @Html.HiddenFor()?
 
no errors.
build succesful
but none of the code is working
control's code *
 
have you restarted visual studio?
Are you storing anything in the GAC?
 
no, since i don't know GAC.
restarting VS.
 
why is this an invalid cast?
  @Html.DropDownList("FlowType", Enum.GetNames(typeof(FlowType)).Cast<FlowType>().Select(o => new SelectListItem { Text = o.GetDescription(), Value  = o.ToString()}), new { htmlAttributes = new { @multiple = true, @id = "FlowTypeDropDown", @data_placeholder = "Select", @class = "form-control" } })
 
2:51 PM
i restarted and still the same issue.
 
@ARr0w it is because your events are not bind to your components
 
how can i bind them back again. While all my controls are in 'groupbox now'
 
Sorry GetValues seems to work
 
War
@KalaJ doesn't getnames return a string array ?
 
yes
 
War
2:58 PM
@KalaJ yeh that's where I was going :)
 
GetValues works and it shows the proper enum
yup
 
click on the component, you will see something like this add-in-express.com/creating-addins-blog/wp-upload/images/2012/…
 
@war, how do I bind an enum to a hiddenfor?
Do you know?
 
War
a single value or the whole enum?
 

« first day (2140 days earlier)      last day (2791 days later) »