This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ============= basicServer101.js ============== */ | |
/* shows | |
- handling Body in a POST (or PUT) request; | |
- two http-request handlers can be hooked up to the same event; both get called one after the other... (just experimenting... we could use one handler with if-then inside it) | |
USAGE: | |
at a cmd prompt enter: | |
>node basicServer101 | |
then at a Browser enter: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//immutable: | |
const { List } = require('immutable'); | |
const someList = List([1,2,3,4,4,4,4]); | |
const uniqueList = someList.toSet(); | |
//ES6: | |
const someArr = [1,2,3,4,4,4,4]; | |
const uniqueSet = new Set(someArr); //==> {1,2,3,4} uniqueSet.constructor is a Set; typeof uniqueSet = "object" | |
const uniqueArr = [...uniqueSet]; //==> [1,2,3,4] uniqueList.constructor is an Array; typeof uniqueList = "object" | |
const uniqueArr2 = Array.from(uniqueSet); //ALT to above line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
break out of loops | |
--------------------- | |
test in node with: | |
>node loops-breakout | |
*/ | |
//+++++ use for -loop; +++++++++++++++ | |
console.log('starting for -loop...'); | |
let selectedRows = {}; | |
//add props(or keys) to object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; //List<> | |
using System.Data.Entity.Infrastructure; //DbRawSqlQuery | |
using System.Data.SqlClient; //SqlParameter | |
using MyNamespace.EFLayer.MyModel; //EFEntities | |
/* executing SELECT field1,field2 from Tablename WHERE pk IN (1,3,5,69) using EntityFramework; | |
---------- | |
place the WHERE clause set in an array, e.g. wherePkeysArray = [1,3,5,69] | |
create a concrete class DTO.ResultObj such that its prop names match exactly the fields in your sql, i.e. field1, field2 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pkSeqNo = 123; | |
//detached entity | |
MyChildEntity child_entity = new MyChildEntity(); | |
MyParentEntity attachedParentEntity = dbCtx.MyParentEntity | |
.Where( h => h.seqNo == pkSeqNo) | |
.Include( h => h.MyChildEntity) | |
.SingleOrDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find tables without primary keys (PKs) in SQL Server database | |
select schema_name(tab.schema_id) as [schema_name], | |
tab.[name] as table_name | |
from sys.tables tab | |
left outer join sys.indexes pk | |
on tab.object_id = pk.object_id | |
and pk.is_primary_key = 1 | |
where pk.object_id is null | |
order by schema_name(tab.schema_id), | |
tab.[name] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
--#1 query to retrieve SERVER/DB | |
select ( | |
select | |
@@SERVERNAME as ServerName, | |
db_name() as DatabaseName | |
-- for XML PATH, root --//<== wraps each record with default <row> element, and supply a default root overall. | |
-- for XML PATH('item'), root('treetop') --//<== when you want to rename 'row' to 'item', 'root' to 'treetop' | |
for XML PATH --//<== default <row> element, no root. | |
-- yields a dodgy column name, say, XML_F52E2B61-18A1-11d1-B105-00805F49916B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//UPSERT 1-M DATA EXAMPLE - insert or update within a transaction | |
//--------------------------------------------------------------- | |
// | |
private void Upsert_OneManyExample(OneManyDto myDtoObject) | |
{ | |
/* ASSUME DTO Object has the form: | |
myDtoObject = { | |
oneHeader = ... some object here | |
} manyLines = ... some array of objects here... | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//set the Web.config for the site which you want to disable dir-browsing; any child folders within the site are also non-browsable. | |
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<system.webServer> | |
<directoryBrowse enable="false"/> | |
</system.webServer> | |
</configuration> | |
//to scope it to a specific folder within the Site or App, use location tag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ctrl/H | |
Search History (optionally, filter your last browser activity) | |
No need to Enter, filters on the fly | |
Works on Chrome and Firefox on Windows; Safari and IE no idea / who cares, but there may be something equivalent. |
OlderNewer