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

14:01
@SteveG same
user47589
damn, i left my pitchfork at home
user47589
David Bowie has died.
@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
14:07
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
14:10
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
@juanvan I'm almost finished!
@Amy Morning.
14:12
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
14:14
@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
that will tell them they have an invite into the Chat
no?
no pm i mean
14:15
@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
14:16
@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
14:17
@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.
14:20
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?
14:24
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;
        }
14:26
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?
14:28
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 ...
14:28
@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.
14:30
@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.
14:31
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
14:31
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();
}
14:32
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?
14:33
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.
14:34
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.
14:36
@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
{

}
14:41
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
14:42
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:
14:45
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>
14:49
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.
14:52
@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?
14:54
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
14:55
@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
:)
14:56
@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.
14:58
@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?
15:05
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.
15:09
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
15:12
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.
15:14
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
15:21
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.
15:27
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
15:28
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
15:30
@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-
15:31
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
can you paste some code?
when your count = 0x0002a262
15:32
@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
15:37
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?
15:41
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
15:42
@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.
15:48
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 (3249 days later) »