Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Ithaqua posted:

I'm guessing they're targeting the people who want something better than MySQL but less expensive than Oracle.

PostgreSQL saddles that range quite nicely. However, I'm excited for the possibility of running a .NET Core website using SQL Server for Linux all on a VPS from Digital Ocean or something for my side projects and taking Windows out of the equation entirely.

Adbot
ADBOT LOVES YOU

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
I also use var everywhere I can. I agree with what other posters have said, that the loss of information from the definition shouldn't be an issue if you have well-named variables and well-named methods. For example, someone posted an example:
code:
var theCake = GetCake();
I don't see anything wrong with this, assume "GetCake()" returns an object of type "Cake". The naming of the variable and the method makes it clear what type is being used there. I've literally never experienced a moment where I've said "I wish there was a type written there instead of var".

Edit: That said, I'm tolerant of both approaches. People do what works well for them. As others have pointed out, consistency is the major concern.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
Edit: nvm I got it figured out.

putin is a cunt fucked around with this message at 12:30 on Mar 8, 2016

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Is there anyway to prevent the EF templates from overwriting modified classes? I have added constructors to the majority of my class I don't want those changes getting nuked every time I run update model from database.

Opulent Ceremony
Feb 22, 2012

Calidus posted:

Is there anyway to prevent the EF templates from overwriting modified classes? I have added constructors to the majority of my class I don't want those changes getting nuked every time I run update model from database.

Haven't done DB-first EF in a while, but aren't the model classes partials? You can just make a new partial file somewhere to add the things you don't want the code-generator to touch.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
Yeah, either use partial classes or change the template to include the extra stuff you want if that's possible. In general you should never modify autogenerated files manually.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
well if feel stupid now, I didn't even realize they were partial classes.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm working on a project in MVC that's used to edit TV channels and is taking the place of a spreadsheet.. So for a given criteria, you have 400 channels being displayed and they want to edit them in line. It's mega slow. Using glimpse, 99% of the slowdown is in ViewResult.ExecuteResult(). I'm running in release mode, I've removed other viewengines besides Razor, and I'm directly linking to the view like this:

code:
  @foreach (var item in Model.Channels)
    {
        @Html.Partial("~\\views\\channel\\_ChannelEdit.cshtml", item)
    }
My partial view looks like this:
code:
@model ECM_UI.Models.ChannelViewModel

@if (Model != null)
{
    using (Html.BeginForm("Save", "Channel", FormMethod.Post))
    {
        @Html.Hidden("MapId", Model.MapId)
        <tr>
            <td>
                @Html.TextBox("Number", Model.Number, new { @readonly = "readonly" })
            </td>
            <td>
                @Html.DropDownList("SourceId", Model.Sources)
            </td>
            <td>
                @Html.DropDownList("ProviderId", Model.Providers)
            </td>
            <td>
                @Html.DropDownList("TypeId", Model.ChannelTypes)
            </td>
            <td>
                @Html.DropDownList("EncryptionId", Model.Encryptions)
            </td>
            <td>
                <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-floppy-o"></i> Save</button>
            </td>
        </tr>
    }
}
I'm not really sure what else to do. Each of those dropdowns is EXACTLY the same except for what's selected in them. Would having each dropdown be a partial view help with caching then? My instinct says that the issue is creating these dropdowns with a ton of data for ~400 records each time, but I'm not sure how I'd get around that and still have the current value for each channel as the selected value.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
What happens if you paginate the results in some way? Just from a UX perspective, displaying a list of 400 items isn't really usable.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Ithaqua posted:

What happens if you paginate the results in some way? Just from a UX perspective, displaying a list of 400 items isn't really usable.
Being able to see all of them at once is an absolute requirement, so I need to approach it from the angle of speeding it up as much as possible.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
How slow is it? I really wouldn't expect just 400 records to cause a significant slowdown.

To get a better idea of what could be causing the slowdown, try using the Stopwatch to time how long it takes to generate the partials, e.g.:

C# code:
@{
    var sw = new Stopwatch();
}
@foreach (var item in Model.Channels)
{
    @Html.Partial("~\\views\\channel\\_ChannelEdit.cshtml", item)
}

@{
    Debug.WriteLine(sw.ElapsedMilliseconds);
}
You can use the Stopwatch in a view and move it around to measure different parts to get a better idea of what could be causing the problem.


Other misc ideas:

Try inlining the partial
Consider manually building the input and select elements instead of using the helpers. The helpers use expression inspection which isn't exactly speedy.


EDIT: also how many Sources, Providers, ChannelTypes, and Encryptions are there?

Bognar fucked around with this message at 15:44 on Mar 9, 2016

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Bognar posted:

How slow is it? I really wouldn't expect just 400 records to cause a significant slowdown.

To get a better idea of what could be causing the slowdown, try using the Stopwatch to time how long it takes to generate the partials, e.g.:

C# code:
@{
    var sw = new Stopwatch();
}
@foreach (var item in Model.Channels)
{
    @Html.Partial("~\\views\\channel\\_ChannelEdit.cshtml", item)
}

@{
    Debug.WriteLine(sw.ElapsedMilliseconds);
}
You can use the Stopwatch in a view and move it around to measure different parts to get a better idea of what could be causing the problem.


Other misc ideas:

Try inlining the partial
Consider manually building the input and select elements instead of using the helpers. The helpers use expression inspection which isn't exactly speedy.


EDIT: also how many Sources, Providers, ChannelTypes, and Encryptions are there?
It's taking ~27 seconds to render the view. 5 encryptions, 9 providers, 601 sources, and 1 channel type.

I initially had the partial inlined, and moved it to a partial thinking it might help.

I'm playing around with stopwatch now to pinpoint.

What would a manually built input/select look like?

B-Nasty
May 25, 2005

Instead of a partial, what if you tried using a @helper method in the main view to render your sub-forms. Calling partial views incurs a significant overhead, and you have that in a loop of XXX items. I'd do a quick test without the form (i.e. just render the drop downs) and see if performance is better. I'll bet it will be.

http://www.asp.net/web-pages/overview/ui-layouts-and-themes/creating-and-using-a-helper-in-an-aspnet-web-pages-site


edit: Beaten, if you tried that, with your update. Can you post the model? Is there anything weird with those properties?

B-Nasty fucked around with this message at 15:39 on Mar 9, 2016

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Uziel posted:

What would a manually built input/select look like?

Disregard that suggestion, you aren't actually using the expression form of the helpers so I don't think you would gain much by manually building it.


Uziel posted:

601 sources

This may be causing the problem? 600 sources on each row by 400 rows is 240,000 total options in dropdown lists.

edit: math! If you just consider the 17 bytes from the string <option></option> then you are generating 4 MB of option tags just for one column of dropdowns.

Bognar fucked around with this message at 15:49 on Mar 9, 2016

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Bognar posted:

Disregard that suggestion, you aren't actually using the expression form of the helpers so I don't think you would gain much by manually building it.


This may be causing the problem? 600 sources on each row by 400 rows is 240,000 total options in dropdown lists.

edit: math! If you just consider the 17 bytes from the string <option></option> then you are generating 4 MB of option tags just for one column of dropdowns.
Yeah, that's insane. Thank you, I didn't think of that. I am trying it without the sources and it's improved but still slow. I'm going to instead have the sources be a modal with the dropdown rendered once.

Uziel fucked around with this message at 16:02 on Mar 9, 2016

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Bognar posted:

PostgreSQL saddles that range quite nicely. However, I'm excited for the possibility of running a .NET Core website using SQL Server for Linux all on a VPS from Digital Ocean or something for my side projects and taking Windows out of the equation entirely.

sql server is amazingly expensive to the point where the windows os license might as well be free

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Malcolm XML posted:

sql server is amazingly expensive to the point where the windows os license might as well be free

It's not the Windows license that bothers me, I just hate managing remote Windows boxes.

epswing
Nov 4, 2003

Soiled Meat
Looks like you're already on track to solving your issue, but I had a couple thoughts about your predicament.

Uziel posted:

Being able to see all of them at once is an absolute requirement, so I need to approach it from the angle of speeding it up as much as possible.

You're trying hard to solve a technical problem but what you really have is a people problem. People are used to a big spreadsheet, where anything is editable anywhere at all times. But they're not using a spreadsheet anymore, are they.

I find myself in this situation often (our clients are in the construction industry, "resistance to change" is an understatement). And often times, you can eventually win your users over, by delivering the facts in a way that shows you're working with them, not against them (eg "it's a clumsy error-prone spreadsheet that only 1 person can edit at a time, or a web page that takes forever to load, trust me you don't want either of those, so let's look at some other options together).

The phrase I end up using, at a strategic point in the conversation, is "in two weeks you won't even remember what the old way looked like" :)

Honestly, I've found as long as you give users a sense that you're going to take care of them, those absolute requirement turn out to be more flexible than you might think.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
epalm, you are absolutely correct. We normally take that approach with users for everything, this is one of those exceptions where developer time is being allocated to replace a spreadsheet for a SINGLE person, and it's entirely political. It's basically been handed down to just do it exactly as this one person wants from 4 levels of management above me. I hate projects like this, but thankfully they are exceptionally rare.

Having multiple dropdowns is the problem it seems. Removing dropdowns entirely makes the view render quickly, so I'll go the modal route for everything.

epswing
Nov 4, 2003

Soiled Meat
Ahh bummer! Sorry to hear you're The Chosen One for "one of those projects" :3:

Calidus
Oct 31, 2011

Stand back I'm going to try science!

LOOK I AM A TURTLE posted:

Yeah, either use partial classes or change the template to include the extra stuff you want if that's possible. In general you should never modify autogenerated files manually.

Any Advice on adding Data Annotations to those auto generated files?

crashdome
Jun 28, 2011

Calidus posted:

Any Advice on adding Data Annotations to those auto generated files?

You can modify the template. Here is an example.

I found it more trouble than it's worth though. Instead of annotations, I just implement it explicitly in the partial class file.

Example:

Auto-gen file
C# code:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SOptimizer.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Collections.ObjectModel;
    public partial class MasterRoll : INotifyPropertyChanged
    {
    	
    	[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public MasterRoll()
        {
            this.MasterRollRuns = new ObservableCollection<MasterRollRun>();
            this.MasterRollAdjustments = new ObservableCollection<MasterRollAdjustment>();
    		runOnce();
        }
    
    	partial void runOnce();
    
        private int _id;
        public int Id { get { return _id; } set { _id = value; OnPropertyChanged("Id");} }
    
        private decimal _width;
        public decimal Width { get { return _width; } set { _width = value; OnPropertyChanged("Width");} }
    
        private decimal _thickness;
        public decimal Thickness { get { return _thickness; } set { _thickness = value; OnPropertyChanged("Thickness");} }
    
        private System.DateTime _createdate;
        public System.DateTime CreateDate { get { return _createdate; } set { _createdate = value; OnPropertyChanged("CreateDate");} }
    
        public virtual ObservableCollection<MasterRollRun> MasterRollRuns { get; set; }
        public virtual ObservableCollection<MasterRollAdjustment> MasterRollAdjustments { get; set; }
    
    	public event PropertyChangedEventHandler PropertyChanged;
    
    	protected virtual void OnPropertyChanged(string propertyName)
    	{
    			PropertyChangedEventHandler handler = PropertyChanged;
    			if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    	}
    }
}
Partial Class file - take a look in particular to the Validate method and also the use of a partial method "runOnce"
C# code:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace SOptimizer.Models
{
    public partial class MasterRoll : IValidatableObject, IDataErrorInfo
    {
        private NotifyCollectionChangedEventHandler remainingLengthHandler;
        partial void runOnce()
        {
            if (remainingLengthHandler == null)
            {
                remainingLengthHandler = (o, i) => { OnPropertyChanged("RemainingLength"); };
                this.MasterRollAdjustments.CollectionChanged += remainingLengthHandler;
            }
        }

        /// <summary>
        /// Checks related data to determine remaining length.
        /// Returns Null if no related data is available
        /// </summary>
        public decimal? RemainingLength
        {
            get
            {
                if (this.MasterRollAdjustments.Count > 0)
                {
                    return MasterRollAdjustments.Sum(o => o.LengthAdjustment);
                }
                else
                    return null;
                
            }
        }

        /// <summary>
        /// Checks for any Consumption towards the roll and returns true if there is any.
        /// Returns Null if no related data is available.
        /// </summary>
        public bool? Locked
        {
            get
            {
                if (this.MasterRollAdjustments.Count > 0)
                {
                    return this.MasterRollAdjustments.Count(o => o.Type == AdjustmentType.Consumption) > 0;
                }
                else
                    return null;
            }
        }

        public DateTime? EarliestStartDate
        {
            get
            {
                if (this.MasterRollRuns.Count > 0)
                    return this.MasterRollRuns.Min(o => o.EarliestStartDate);
                else
                    return null;
            }
        }

        public bool? HasRush
        {
            get
            {
                if (this.MasterRollRuns.Count > 0)
                    return this.MasterRollRuns.Count(o => o.HasRush.HasValue ? o.HasRush.Value : false) > 0;
                else
                    return null;
            }
        }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Width <= 0)
            {
                yield return new ValidationResult
                 ("Must be greater than Zero", new[] { "Width" });
            }
            if (Thickness <= 0 || Thickness > 1.0m)
            {
                yield return new ValidationResult
                 ("Must be between 0.000 and 1.000", new[] { "Thickness" });
            }
        }

        public string Error
        {
            get { return string.Empty; }
        }

        public string this[string columnName]
        {
            get
            {
                return this.GetErrorMessage(columnName);
            }
        }
    }
}

Calidus
Oct 31, 2011

Stand back I'm going to try science!
Your my Hero.

crashdome
Jun 28, 2011

Calidus posted:

Your my Hero.

Well, in that case let me throw this out there too so it's complete. You'll notice an extension method in my validation partial class.
It's not mine. I had trouble finding the source page but, I pulled it from somewhere.

C# code:
    
    public static class IDataErrorHelper
    {
        public static string GetErrorMessage<T>(this T entity, string columnName) where T : IValidatableObject
        {
                string message = null;
                var data = entity.Validate(new ValidationContext(entity, null, null));
                switch (columnName)
                {
                    case "":

                        foreach (var item in data)
                        {
                            message += item.ErrorMessage + Environment.NewLine;
                        }
                        break;
                    default:
                        foreach (var item in data)
                        {
                            if (item.MemberNames.Contains(columnName))
                                message += item.ErrorMessage + Environment.NewLine;
                        }
                        break;
                }
                if (message == null)
                    return null;

                return message.TrimEnd(Environment.NewLine.ToArray()); 

        }
    }

raminasi
Jan 25, 2005

a last drink with no ice
The customer service drone I am communicating with about a frown I sent just cannot wrap her head around the idea of a program that runs without crashing yet still demonstrates a failure mode. I sent the demonstration project. I sent expected output. I sent actual output. The response: "It's building and running, please send exact reproduction steps." Yes, I know it's building and running, that was never the problem :suicide:

22 Eargesplitten
Oct 10, 2010



If I type in something that's part of a built-in method and then type something else like "." it auto-completes that method. How do I get it to not do that? I'd rather have it set to where I hit a button to confirm I want that completion.

ninjeff
Jan 19, 2004

22 Eargesplitten posted:

If I type in something that's part of a built-in method and then type something else like "." it auto-completes that method. How do I get it to not do that? I'd rather have it set to where I hit a button to confirm I want that completion.

press escape

22 Eargesplitten
Oct 10, 2010



So there's no way to set it to not auto-complete by default? I really hate how that's becoming normal.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
There's a way, although it may not give the exact behavior you're looking for. If you press Ctrl + Alt + Space you'll toggle Intellisense between Completion Mode and Suggestion Mode. In Suggestion Mode it'll show the list of candidate symbols but it will never auto-complete by itself. If you press Tab it will fill in what it considers the most likely candidate (i.e. the same one it would autocomplete with in Completion Mode), or you can use the arrow keys and Enter to select another entry in the list.

22 Eargesplitten
Oct 10, 2010



Awesome, that's exactly what I'm looking for. That's similar to Eclipse.

Essential
Aug 14, 2003
We're getting ready to build a web portal for internal and public operations. Seeing the recent talk here around asp.net 5/core, is it not advisable to use this for creating an azure web app? Everything will be running on azure, including using Azure AD for authentication.

I was a little confused if you guys didn't think it was ready at all for production use or only in certain configurations (Linux/mac/etc).

Essential fucked around with this message at 05:23 on Mar 14, 2016

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Essential posted:

We're getting ready to build a web portal for internal and public operations. Seeing the recent talk here around asp.net 5/core, is it not advisable to use this for creating an azure web app? Everything will be running on azure, including using Azure AD for authentication.

I was a little confused if you guys didn't think it was ready at all for production use or only in certain configurations (Linux/mac/etc).

The RCs have stabilized a bit but I think it's still a bit immature. You're going to be scratching your head a lot and dealing with dependencies that are still being updated and breaking on a pretty regular basis.

I love the approach they're taking and it's going to be wonderful, but it needs time to mature. Super looking forward to being able to Dockerize applications.

Essential
Aug 14, 2003

Ithaqua posted:

The RCs have stabilized a bit but I think it's still a bit immature. You're going to be scratching your head a lot and dealing with dependencies that are still being updated and breaking on a pretty regular basis.

I love the approach they're taking and it's going to be wonderful, but it needs time to mature. Super looking forward to being able to Dockerize applications.

Got it, thanks Ithaqua! With how quickly we are hoping to have this up and running I don't want to add unnecessary headaches.

brap
Aug 23, 2004

Grimey Drawer
Wait a year.

EssOEss
Oct 23, 2006
128-bit approved
Yeah, I would not go production with Core before 2017. It is still raw as hell.

Diabolik900
Mar 28, 2007

My company has some old MVC 3 apps that we want to upgrade. One issue we've run into is that starting in MVC 4, they changed the way they render boolean values in html attributes.

Previously this:

code:
<input type="text" value="@true" />
<input type="text" value="@false" />
would render as this:

code:
<input type="text" value="True" />
<input type="text" value="False" />
but now, it renders as this:

code:
<input type="text" value="value" />
<input type="text" />
I understand why they made this change, but it's going to be a major undertaking to fix all of our code. Are there any options to get back the old behavior, or will we have to manually go through and update all of our code?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Unfortunately there's no way to toggle that rendering option site-wide, to my knowledge. You can simply call .ToString() on all your boolean values to get the old behavior back, but that doesn't help you find all the places it's used. If you're lucky and people used ViewModels for all your Views and avoided the use of ViewBag, then finding all the usages shouldn't be too hard.

ReSharper's structural search and replace would make this amazingly easy if only it supported Razor syntax (it does C#, HTML, CSS, and JavaScript, but no cshtml).

Diabolik900
Mar 28, 2007

Bognar posted:

Unfortunately there's no way to toggle that rendering option site-wide, to my knowledge. You can simply call .ToString() on all your boolean values to get the old behavior back, but that doesn't help you find all the places it's used. If you're lucky and people used ViewModels for all your Views and avoided the use of ViewBag, then finding all the usages shouldn't be too hard.

ReSharper's structural search and replace would make this amazingly easy if only it supported Razor syntax (it does C#, HTML, CSS, and JavaScript, but no cshtml).

Thanks. That's basically what I figured. This was pretty much just a last ditch effort to avoid hunting for every instance.

Calidus
Oct 31, 2011

Stand back I'm going to try science!
View Components look promising but Partial Views got axed after 2 .net revisions so it kinda makes me want to stay way from them. I also don't see a huge advantage when compared to just using json and js.

Adbot
ADBOT LOVES YOU

Essential
Aug 14, 2003
Any advice on how to securely store an access token in Azure? We're going to start reporting on our customers QuickBooks data via an automated process, which means we need to store the qb access token after the user puts in their credentials.

The users will be in Azure AD and we have access to any/all azure services that may be needed. In doing some research I've seen a suggestion of creating a Claim (I think membership claim?) for users authenticating via the standard asp.net authentication. I'm assuming there must be a secure storage spot for this in Azure AD membership?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply