I have json stored in a string field. There is a board_code node in the json. The sql to select just the board_code value out of those strings is:
SELECT JSON_VALUE(ColumnName, ‘$.board_code’) AS BoardCode FROM TableName;
I have json stored in a string field. There is a board_code node in the json. The sql to select just the board_code value out of those strings is:
SELECT JSON_VALUE(ColumnName, ‘$.board_code’) AS BoardCode FROM TableName;
NHibernate was giving me fits, not letting me use ‘.In’ in the linq statements.
Here is how I got it to go:
IQueryable<int?> idsForOrgList = _repo.Get<OrganizationThingyXref>().Where(thingy => thingy.OrganizationID == orgId && thingy.IdICareAbout != null).Select(_=>_.IdICareAbout);
List<People> ThingysInOrg = _repo.Get<Thingy>().Where(_ => idsForOrgList.Contains(_.IdICareAbout)).ToList();
I was struggling to E2E Selenium test a repeater, in a user control, in an old .net webforms page – tall ask right?
Here is the solution I came up with:
I added a custom attribute (“data-serviceid”) to the element the repeater is drawing – inside the code behind of the user control (a link button in this case):
var lbNewReport = (LinkButton)args.Item.FindControl("lbNewReport");
lbNewReport.Attributes.Add("data-serviceid", myServiceId);
Then I used this static helper method for selenium:
public static By SelectorByAttributeValue(string attributeName, string attributeValue)
{
return (By.XPath($"//*[@{attributeName} = '{attributeValue}']"));
}
With This call:
var linkIWant = _driver.FindElement(SelectorByAttributeValue("data-serviceid", myServiceId));
And voila – I have the control in hand that I want to interact with(clicking in this case for me).
if (select count(*) from neatoSchema.YourTable where SomeColumnYouCanCheckDataOn = 2018)> 0 begin print 'That row is already inserted' end else begin INSERT into neatoSchema.[ConferenceDate] (... your data ...) end
You can also interrogate information_schema.tables or information_schema.columns if you are doing a change to a table to ensure that doesn’t run twice!
If you dynamically add controls with ajax, javascript doesn’t see those controls unless you hang the method on the document.body like this:
$(document.body).on(‘keyup change blur’,
‘.dateTaken’,
function (event) {
enableOrDisableSaveButton();
});
This watches keyup, change, and blur on an element that has the class dateTaken.
I think that most days, code remodeler would be the right job title for a lot of us. We take working code and just make it better working code.
The book that got me started thinking of myself as a ‘code remodeler’ is Refactoring: Improving the Design of Existing Code by Martin Fowler.
If you haven’t read it, go get it quick! (Of course, and then read it…) Fowler lays out refactoring techniques in a straightforward way. You can start applying it immediately. I use Replace magic number with symbolic constant and Extract Method almost every day when I am helping a team with an older codebase.
Thanks for stopping by, and happy coding,
-Jim
function mySweetClickEvent(event) {
event = window.event || event; //NOTE: another lovely hack to make Firefox work…
var target = event.target ? event.target : event.srcElement; //NOTE: another lovely hack to make IE work
var senderToUse;
if (target) {
senderToUse = target; //this works for ie and chrome
} else {
senderToUse = event; //this works for firefox
}
…do stuff with the sender here…
}
var emailsDontMatchError = new CustomValidator { ValidationGroup = "Main", IsValid = false, ErrorMessage = "E-mail addresses do not match" }; Page.Validators.Add(emailsDontMatchError);
/* This container keeps its aspect ratio */
/* padding-bottom actually sets the height proportionally to the width – yep, doesn’t seem logical right? */
.container {
position: relative;
height: 0;
padding-bottom: 50%;
}
/* properly aspected element inside the container */
.element {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
I was having trouble properly formatting a table in html with css and I found this on Stack Overflow.
Replace cellpadding with:
th, td { padding: 5px; }
Replace cellspacing with:
table { border-collapse: separate; border-spacing: 5px; } // cellspacing=”5″
table { border-collapse: collapse; border-spacing: 0; } // cellspacing=”0″
Replace valign with:
th, td { vertical-align: top; }
Replace align (center) with:
table { margin: 0 auto; }
The original article is here.