
You have taught me so much that I was curious about and so much about what I didn't know I wanted to know. Keep up the good work.
Here you'll find compiled thoughts on software development, technology and occasionally general life matters from me, Peter Lanoie.
"I find that when someone's taking time to do something right in the present, they're a perfectionist with no ability to prioritize, whereas when someone took time to do something right in the past, they're a master artisan of great foresight."
Where do you put something like this in your MVC project? This is a specific extension method, probably in a file by itself. Do you have a specific structure (directory / folder) you use for this? Do you have a generic /common folder or something?
public static void CleanAllBut(
this ModelStateDictionary modelState,
params string[] includes)
{
modelState
.Where(x => !includes
.Any(i => String.Compare(i, x.Key, true) == 0))
.ToList()
.ForEach(k => modelState.Remove(k));
}
ModelState.CleanAllBut("username", "password");
MVC.Shared.Views.PlantListPager
MVC.Shared.Views.PlantListPager_cshtml
// View file extensions to exclude from the generated links
readonly string[] ExcludedViewFileExtensions = new string[] {
".cs"
};
if (ExcludedViewFileExtensions.Any(extension =>
item.Name.EndsWith(extension, StringComparison.OrdinalIgnoreCase)))
continue; // ignore defined extensions
System.Web.Mvc.WebViewPage
@inherits <class name>
@inherits MySite.Views.Home.Index
~/Views/Home/Index.cs
~/Views/Home/Index.cshtml
namespace MySite.Views.Home
public abstract class Index : WebViewPage
{
// ... my super-duper code goes here
}
}
<pages masterPageFile="~/Views/Shared/Site.Master">For Razor it's in the view start file for your chosen language, in my case it's C# (_ViewStart.cshtml):
...
</pages>
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@Html.Partial("mypartialview")
or
<% Html.RenderPartial("mypartialview"); %>
@{
this.Layout = null;
}
ZoneMin tinyint
ZoneMax tinyint
SELECT
MIN(ZoneMin) MinMin, MAX(ZoneMin) MinMax,
MIN(ZoneMax) MaxMin, MAX(ZoneMax) MaxMax
FROM Plant
Plants.GroupBy (p => 0).Select (p => new {
MinMin = p.Min (x => x.ZoneMin),
MinMax = p.Max (x => x.ZoneMin),
MaxMin = p.Min (x => x.ZoneMax),
MaxMax = p.Max (x => x.ZoneMax)
})
-- Region Parameters
DECLARE @p0 Int = 0
-- EndRegion
SELECT
MIN([t1].[ZoneMin]) AS [MinMin], MAX([t1].[ZoneMin]) AS [MinMax],
MIN([t1].[ZoneMax]) AS [MaxMin], MAX([t1].[ZoneMax]) AS [MaxMax]
FROM (
SELECT @p0 AS [value], [t0].[ZoneMin], [t0].[ZoneMax]
FROM [Plant] AS [t0]
) AS [t1]
GROUP BY [t1].[value]