« first day (1913 days earlier)      last day (3026 days later) » 

2:01 PM
@SteveG same
 
user47589
damn, i left my pitchfork at home
 
user47589
David Bowie has died.
 
Yea
 
@Amy Sad Day for Dance Magic
 
user47589
the universe is billions of years old, and we somehow managed to live at the same time as David Bowie.
 
user47589
2:07 PM
salutes
 
you need one of these
 
user47589
thats cute
 
user47589
i want it
 
target
1 message moved to Orphan GIFs
 
What does "Non-static method requires a target." really mean?
by the way, Hi @juanvan
 
2:10 PM
Need a constructed object passed
Hi Code!
 
I'm getting this error message during User update
and it points to:
var userProfile = await db.UserProfile.FirstOrDefaultAsync(x => x.User.Id == user.Id);
I actually used the Identity sample package but I still have this weird error.
 
Morning everyone.
 
user47589
hi greg
 
Hello
 
@juanvan I'm almost finished!
@Amy Morning.
 
2:12 PM
Rather newbie question, is there a way to invite people into chats via commands? I can't seem to invite someone just straight off the bat.
 
Has anyone ever setup their own Owin server without Microsoft's middleware?
 
user47589
i dont think so @Xariez
 
user47589
hm, i set up an owin server on my raspberry pi
 
@Greg that is Great news
 
user47589
but i think it was still MS
 
2:14 PM
@Xariez yes you ping them
 
Alright, follow up question. Is there ANY way i can contact someone via stackoverflow directly? PM? Messages?
/ping Fe De
well that was..
not as expected
 
no
 
that will tell them they have an invite into the Chat
no?
 
no pm i mean
 
2:15 PM
@Amy Trying to avoid their Identity Server, it is a bit bloated. Was hoping to go a bit more light weight.
 
you can create a chat and ping them, that's the only way
 
ok thought so
 
but keep in mind, all chat is public viewable
 
Alright. How do i go about pinging them, then?
 
user47589
usernames aren't unique. there's another "Amy" out there
 
2:16 PM
@Xariez
 
Oh right
Didn't think it was that simple
 
Amy Farrah Fowler?
 
@CodeMaster Does it exist any user with that particular Id?
 
@scheien No, I only have one user in my DB
 
2:17 PM
@juanvan Check it out, I just have to grout, do the electrical / hdmi wall plate, and remove the wood holding the top pieces in a couple days once the cement hardens.
 
That was lot of work over the weekend?
 
@FeDe
 
The bottom part took about five hours, the top part took about 12 hours, but yeah.
 
ya, had the top done
 
@scheien I'm so stuck with this, I can't even move to the next part of the project.
 
2:20 PM
Does it look good though?
 
Its a wide topic, but using EF and ASP.net, is there a relatively simple way to create a database connection to a "remote" DB? (Kind of the equivalent of PHP's mysqli_connection();). If this is way too much to cover on here thats one thing, but i need to ask.
 
Then over this week I'll finish the electrical, lay the ply wood, lay the sound dampening on the plywood, then lay the hard wood floor.
 
@Xariez Yeah, in your config you simply put the connection string. Just make sure you have permission to login.
 
@CodeMaster there are two lines of same code trying to get userProfile , which line is throwing exception?
 
2:24 PM
Alright. As a follow up question (didn't find this at ALL on the interwebs), how do I go about adding things onto it? (I remember PHP had something like $insert = INSERT INTO [db] (), (), but i doubt its that easy here with all honesty)
 
@tweray line 65
 
@Xariez That is almost identical to raw SQL, but if you have a generic Repository which holds your save logic, it is as simple as context.Save().
 
@tweray when I load the UserUpdate page everything loads as expected but as soon as I hit Update things start to act differently.
 
@Xariez For your first question, it's just a matter of using the right connection string. EF connects to the DB using the connection string defined in web.config. You can set that to a remote DB, assuming it's accessible.
 
@Xariez A more detailed of the save method you would potentially create:

        T IContext.Save<T>(T entity)
        {
            this.Attach(entity);
            SaveChanges();
            return entity;
        }
 
2:26 PM
Creating a list should be relatively easy (have done it in Console coding), but that probably resets each time the page loads, on the other hand, i remember I once wrote something like:

var db = (from a in db.table (where a.name == name(select db.a)); , but i honestly cant remember if that was naywhere close to it
 
found my problem. Had another style on TextBlock which overwrote the Trigger.
 
@Greg if he understands that I would be amazed
 
try this:
var targetId = user.Id;
var userProfile = await db.UserProfile.FirstOrDefaultAsync(x => x.User.Id ==targetId);
 
@Xariez For your second - if you want the simplicity of raw SQL calls into the DB, you can just skip EF and do that directly with an SqlConnection/SqlCommand. It's usually a bad idea for anything except the most trivial code in non-production environments.
 
@juanvan Not a larger grasp of that?
 
2:28 PM
Alright. Care to share a example? @AvnerShahar-Kashtan
 
<T> ? he is looking for some simpler
 
@Greg Yeah, the "this.Attach(entity);" and SaveChanges(); is something i definetely recognize, the rest, not so much
 
the SaveChanges
is what you Need to understand now
 
Yeah, if you want raw SQL just do:

using(var connection = new SqlConnection(ConnectionString))
using(var comman = new SqlCommand(query, connection))
{
     connection.Open();
     command.Parameters.AddWithValue(..., ...);
     command.ExecuteNonQuery();
}
 
that is the Insert INTO TABLE ...
 
2:28 PM
@tweray let me try.
 
@juanvan Non Generic.
 
@Greg I'm assuming you ment (using var command = ..) ?
Instead of comman ?
 
Raw SQL is usually not the way to go in C#. It's even more infuriating than working with EF.
 
EF all the THINGS!
 
@Xariez EF is an ORM, meaning it maps classes to DB tables. You need an initial modeling phase - either creating your tables in the DB and then generating code for entities based on it, or code-first, just creating C# classes with appropriate attributes.
 
2:30 PM
@Xariez Yeah
I agree with @RoelvanUden.
 
Object reference not set to an instance of an object.
var targetId = user.Id;
 
@CodeMaster then you get the problem
user is null
 
I'm not sure if it helps, but all i am making is pretty much a "log" where users can input different fields. I would create the DB, then a table, add the fields and then try to add things to those fields, then grab it and print it out onto the list (which i could imagine uses foreach?)
 
For EF, you'll create a DbContext object wtih a DbSet<MyObject>, which behaves a lot like a List<MyObject> but is where the mapping to the DB happens. Just add a new instance of MyObject to it and call SaveChanges.
 
2:31 PM
take a look a that - it shows the old way and the new way
 
Why don't you use static analyzers to avoid even writing code against nulls?
 
@tweray the user is null during Update?
 
And also, its a MySQL DB
 
With EF you could do:

        IList<T> IContext.ExecuteStoredProcedure<T>(string procedure, params SqlParameter[] parameters)
{
     return this.Database.SqlQuery<T>(procedure, parameters).ToList();
}
 
^ all the same
 
2:31 PM
Something a long those lines.
 
That link doesn't look bad. Will have a look at that!
 
Come back when you get that idea
making an Entity object
attaching it to a DB context save it
 
Roger that
 
@CodeMaster var user = await UserManager.FindByIdAsync(editUser.UserId); basically get you a null user, and your null check didn't cover the next line
 
using (var db = new LogDbContext())
{
     LogItem item = new LogItem() { properties...};
     db.LogItems.Add(item);
     db.SaveChanges();
}
 
2:32 PM
THAT is something i very much recognize from earlier
When using local databases
 
@tweray ok, as you see editUser is actually a ViewModel, do I need to point it to Model?
 
I swear my web forms code was working a while back (it can compile, etc..) and now that I try to run it again, I'm getting a bunch of validation errors
 
where do you...how do you..
 
I get something like: Compiler Error Message: BC30456: 'ValidateAge' is not a member of 'ASP.main_aspx'.
 
how do you actually make the code see that thats where the data should get added to the db?
 
2:33 PM
why would that message appear?
 
@Xariez ` db.LogItems.Add(item);`
that adds to the Context to be saved
 
@CodeMaster no, you just need to figure out why your UserManager.FindByIdAsync(editUser.UserId) returns null, my bet is that your userid from viewmodel is empty or something, but i'm not on your computer, simply debug through it and you will see
 
then the SaveChanges executes teh SQL
 
I see, okay
 
@Xariez The code doesn't care. That's what the connection string is for.
 
2:34 PM
Ah, that explains it.
 
@Squiggle Do you have an elegant solution to allow you to do ParentEntity.Children.Remove(child) and cause an actual delete on the child object, rather than setting its FK to null?
 
@Xariez One of the major points being left out, these "context" we keep referring to is a class file, that contains your Entity Framework configuration / methods of implementation. It holds key data in some instances, like how to map a database to a model, also several other aspects.
@RoelvanUden Have you ever implemented an OAuth Server without Microsoft's IdentityServer? Was hoping to do an OAuth server, that was a bit more lightweight.
 
I see, okay, yeah I'm seeing it doesn't just want to accept "using (var db = new LogDbContext())", so clearly i have to give it somewhere to actually use that context
 
@Greg Sorry, I haven't.
 
@RoelvanUden Bummer, the documentation is almost non-existent.
 
2:36 PM
@tweray Thanks, I will look deeper. I just did the Debug and yes the user is Null.
 
@Greg Read the spec I suppose?
 
@RoelvanUden That is what I started doing.
 
Can i ask this, when i have set the code up as it should be, how do i go about actually "linking" LogDbContext() ?
Because right now it can't obviously find the namespace or type
 
Can you post the code you have in a pastie.org and link it back here
 
`LogDbContext` would be a class, or an object. Ie:

1. Add New Item
2. Add class
3. Name it LogDbContext

That would create:

public class LogDbContext
{

}
 
2:41 PM
Apparently, opening up the web forms app in an older visual studio version helped
 
Visual Studio 6.0?
 
haha
 
Sad I have that loaded on this pc :(
 
I used Visual Studio 2012, I used Visual Studio 2013 and I got a bunch of random validation errors
If 2012 didn't work, I would do 2010
 
Yeah, I see that. Still not sure how to actually push it to the DB though, lol
 
2:42 PM
Ya keep going back - should check the sln file for the vs version
 
Or hold on, is that the SqlCommand Object?
 
db.SaveChanges()
 
Thats found on the second step of the link you sent me?
 
ya
that guy references an older version of EF tho, so its' Add not AddObject
 
@juanvan Is it the old ObjectContext vs DbContext?
@Xariez Get this:
 
2:45 PM
Ya, he does not go Into that, it is a here is how this works blog, not a Follow along type
 
@juanvan That transition was EF 4 right?
I mean ObjectContext still exist, but it has been transitioned to the short hand DbContext for the most part?
 
Ya 4 think updated that
or changed it
it was no longer a : I? i don't remember tho
 
@Xariez I have this DbContext class in my project:
public class SystemDbContext : DbContext
    {
		public SystemDbContext() : base("SystemDBConnection")
        {
See the constructor? it calls the base DbContext constructor, passing in the name of a connection string.
In my server processes' app.config (it would be web.config for an ASP.NET project) I have a ConnectiontStrings section:
 
@AvnerShahar-Kashtan I think the blog he is looking at is doing:

public class LogDbContext : ObjectContext
{

}
 
      <connectionStrings>
        <add name="SystemDBConnection" connectionString="Server=remote_server;Database=my_database;Trusted_Connection=True;" providerName="System.Data.SqlClient"/>
</connectionString>
 
2:49 PM
Ya, that blog was just to be an Idea of how the code flows, not a Tut
 
Now EF will look for the named connection string in the config file and use that to connect.
 
Is it UID for Username and PWD for Password, or am i completely out in the wind here?
 
Importing 2k tables to a DB has taken about 1 second per table, that a good rate?
 
depend on how big are the tables
 
@Xariez That's up to MySql.
Connection strings are DB-specific. That's why they're just strings. Each DB could have different syntax.
 
2:52 PM
@juanvan that entirely depends on the amount of data/table, the size itself of the table and your hardware
 
Ya it was kinda an ambiguous ?
 
I'm more curious what kind of database you've that has 2k tables.
 
one that is Not normalized
 
the biggest I've ever seen had ~400 tables and that was only because the person that designed it thought it'd be wise to make every table relation n:n. Which meant he had to have a mapping table for every relation.
 
How do you even manage to maintain a db with 2k tables?
 
2:54 PM
slowly?
 
I create and destroy it at will
 
Does it come with a 500 page manual?
:)
 
I take a MAIN db and create this other Database everytime
 
It's really rare I exceed 20 tables :/
 
In my head
 
2:55 PM
@RoelvanUden finally something we definetly have in common ;)
 
@scheien the manual is about 50 pages
my biggest DB has 4k tables
 
@RoelvanUden: yeah, ours usually land on roughly the same count
 
curious about how they name those tables
 
But I create those 4k tables from maybe 800 tables
 
Axxxxx
Bxxxxx
:)
 
2:56 PM
@SteffenWinkler We have lots in common! We're both amazing people, modest, talented, beautiful, smart, intelligent...
 
@tweray well, that's easy: tab_1, tab_2, [...] tab_2000
 
A2015SOMEMODELNUMBER
 
@RoelvanUden yes yes, indeed
 
how beautiful is there if you are a anime character and he's a pixel art
 
Those are irrelevant details.
 
2:58 PM
@tweray hah, that's only because SO can't handle @RoelvanUden's and mine combined beauty.
2
 
I'll need to ask this before continuign with the codetunnel link you sent me, can one create a local database via visual studio, move the whole "package" onto a remote server using WinSCP, and then have it work like any other MySQL database?
 
Visual Studio installs a SQLExpress package
that is what the V11.0 is in the App.config
 
@Xariez EF is capable of creating the database structure from code, as well as migrating it, etc. So when you use EF Code First with migrations enabled (you'll come to this later), publishing your site should be as easy as running publish from VS.
 
So to conclude it, can i create a database strictly from visual studio and use that database to store the user data? Or would that break?
I see theres a Publish option, but im not sure since i've never actually tried it
 
Why would it break?
 
3:05 PM
I was thinking if it has to have Visual Studio specifically running in the background for the database to actually..work?
Since that is from where you create it afaik?
 
This isn't PHP; there is no built-in if (rand(0, 1) < 0.25) die(generateError()) in C#
@Xariez Of course not. It depends on what your connection string says. Most just point to an existing MSSQL (or MySQL in your case) instance
 
@RoelvanUden no instead we got the .suo file from VS
 
By default, VS might use SQExpress which is indeed short-lived while VS is open. It's intended for development purposes to make it easier to get started. That doesn't mean you can't configure it to use any db you want
 
Okay
 
e.g. I run my dev against the same mssql server version we use in prod.
 
3:09 PM
I just realised.. is there a good way to know wether my web host can "run" Asp.net? I know it can run PHP but..
 
Look into their hosting. 9/10 times a cheapo PHP host won't run ASP.NET.
But hey, there are cheapo ASP.NET hostings, it's no reason to return to an inferior platform.
 
I am more and more thinking i should just have done this in PHP, considering the web host I have is linked with my school, so i get it free, kind of
problem is, after using c#'s variables, i am really really really really unused to php, lol
 
have an async program, it works but how can I flag when all the Async items are done?
 
posted on January 11, 2016 by ericlippert

Happy New Year everyone; I hope you had a pleasant and relaxing festive holiday season. I sure did. I’m starting the new year off by giving a short — an hour long or so — talk on how you can … Continue reading →

 
@Xariez To be honest and fair, there's nothing all that wrong with PHP if you use it correctly. But you'll soon find that C# simply offers better libraries and compile-time protection, which accelerates your development by miles (once you get the hang of it). There is almost never a reason to choose PHP over C#.
@juanvan .ContinueWith
 
3:12 PM
I can definetely see that, yeah.
Its worse if the server cant run it though
 
@RoelvanUden and if your on windows the tooling is very good as well
 
@RoelvanUden thanks!!
 
@AlexL Too true.
 
Right, if i were to try it, what do i pull from my code to get a version ready to get pushed to a remote host? @RoelvanUden
I feel like if i just grab my .aspx and .css file, its all going to fall apart
 
@Xariez Right click your web solution, and press publish.
 
3:14 PM
Okay.
You don't happen to know the shortcut in VS to comment out everything you've highlighted?
 
There's a button in the toolbar, but I don't know the shortcut.
 
CTRL+k, Ctrl+c apparently
 
@RoelvanUden You don't belong in this community with that attitude
 
@KendallFrey stop being so envious of @RoelvanUden's versatile mind!
 
If i want to throw it out manually via WINSCP, how do i go about setting it up? Most of it seems to be pushing it up from VS
 
3:21 PM
have a good evening everyone!
 
@Xariez I wonder why you'd want to use that, but okay, just publish to zip, upload the contents of the zip, and you're good to go.
@SteffenWinkler Have a great evening oh beautiful one!
 
The contents of it? Roger that
 
That is, if your host is setup to run .net web apps :p
 
Yeah, we'll see that in a minute. Much why i'm testing
Do i need to include the .SetParameters and .SourceManifest XML documents? :o
That was outside the .zip
Also , does not look like they accept .net files. Just showing the raw code. Ah well.
 
I don't know what they are. I suppose they are inherent to the type of content you have in your app. Sounds like you were doing Web Forms or some other old-school aspx bull, so yeah, there might be additional crap for that.
That's usually the case for them cheap Linux boxes.
 
3:27 PM
When deploying to IIS, what publish method do you usually select?
 
Ah well. That at least makes me not have to ask a billion questions on here
 
@Xariez Oh? You're giving up then?
@KalaJ File System :P
 
yeah okay and where do you usually choose for path
Is local disk C okay?
 
Not giving up, but its not like i can do much with a host not "accepting" .net :P
 
@KalaJ The shared disk that lives on the web server :P
 
3:28 PM
hmm actually I have a question about that
 
haha got a lovely customer.. Dem arrogant bastards who thinks they knows everything, but all they can come up with is crapz
 
I need to set the path and then configure the setting using IIS on a remote web machine
how will the remote machine know the path where I publish to on my current machine?
 
user47589
any thoughts? this is the last bit i need to work on before this project is completed: stackoverflow.com/questions/34724433/…
 
user47589
i'm stuck
 
I'm having trouble opening a database immediately after I create it, in code
 
3:30 PM
@KendallFrey EF?
 
Any off-the-cuff ideas why I couldn't open a connection immediately after running a CREATE DATABASE?
@Failsafe ADO.NET
I think?
 
Can you verify the table was created?
 
use db; ???
 
-AFK-
 
3:31 PM
Whatever SqlCommand is
 
close and reopen the connection?
 
@JakobMillah That worked if I use the existing connection, but I need to open a connection to the DB
 
I see
 
can you paste some code?
 
when your count = 0x0002a262
 
3:32 PM
@Failsafe I'll try to get something
new SqlCommand("CREATE DATABASE Foo;" connectionToMaster).ExecuteNonQuery();
new SqlConnection(connectionStringToFoo).Open();
fails on open
 
lol
wait
oh i misread nvm
 
@KendallFrey have you grant necessary access for your user after create the db?
 
99% sure it's not a permission issue
 
I guess you just failed to add the "," in the code here @KendallFrey? In the SqlCommand method
 
the what
 
3:37 PM
comma
new SqlCommand("CREATE DATABASE Foo;", connectionToMaster)
 
typo, not in my actual code
 
thought so..
 
what's the exception msg then?
 
Cannot open database "Foo" requested by the login. The login failed.\r\nLogin failed for user 'KENDALL-WS\Kendall'
 
can you open it from server explorer?
or by any other sql programs?
 
3:41 PM
yeah, creating the database is working fine
 
Does anyone get the adobe flashplayer plugin failure message on chrome? I'm curious why it happens only intermittantly
 
I think it also works if I add a delay between creating an opening
@KalaJ No, why would anyone use Flash?
 
what if you use the "using" structure+
 
do you open a connection inside another connection?
 
I don't know chrome keeps saying my flash pluging crashed
on windows 10
 
3:42 PM
@KendallFrey dude, u sure it's 99% not permission issue? maybe 98%?
 
@tweray that's not what I said
@Failsafe maybe
 
well don't do that
 
That is your problem then
But you can open connections inside connections using "using"
 
using(SqlConnection con = new SqlCOnnection(foo){
con.Open();
//create database
con.Close();
}
using(SqlConnection con = new SqlCOnnection(foo){
con.Open();
//do other shit
con.Close();
}
also put your stuff in try catch blocks if you haven't already
sometimes ADO will leave connections open if you dont catch
ive been deadlocked by that before
 
Shit happened to me in my biggest Uni project.. Was stuck with that for a couple of days haha.
 
3:48 PM
tfs :(
 
works fine for me :D
 
For entity framework what is best practice for storing / accessing data with the context?

For example if I have a contact Object, should I add a public method to contact where I can:
Contact.SaveChanges()
{
     //using(context)
     {
          //if insert context.add()
          //if update ...
      }
}

?
 
Could anyone give me some opinions on how to use these methods asynchronously without using the (apparently much disliked) await Task.Run(() => snmp.Walk(SnmpVersion.Ver1, entryOid));? This is really just to try and prevent the UI from locking up while the queries happen. This current method I'm using (Task.Run) also seems to screw up System.NullReferenceException-style when multiple queries try and happen simultaneously.
 
here is a demo, used to make my current program
https://msdn.microsoft.com/en-us/library/hh300224.aspx
 

« first day (1913 days earlier)      last day (3026 days later) »