Monday, May 08, 2017

The equivalent to lambda expressions in Angular TypeScript (Javascript)

For filtering a list in C# we have :

var filteredList = List.Where(l => l.active);]

JS equivalent :

var filteredList = list.filter((l) => { return l.active == true; });


C# - Test for list values

var isListPopulated = List.Any( l => l.amount >= 0);

JS - Test for list values

var isListPopulated = list.filter((l) => { return l.amount >= 0; }).length > 0;


C# - Get first list item

var topItem = List.First( l => l.amount >= 0);

JS - Get first list item

var topItem = list.filter((l) => { return l.amount >= 0; })[0];

NB C# First() throws an exception if there is no match. As does the JS equivalent.



C# - Get first list item or null if none exist

var topItem = List.FirstOrDefault( l => l.amount >= 0);

JS - Get first list item or null if none exist (combo of the Any + First)

var filteredList = list.filter((l) => { return l.amount >= 0; });
var topItem = filteredList.length > 0 ? filteredList[0] : null;

Thursday, April 27, 2017

Resolving "Invalid column name" Exception

"System.Data.SqlClient.SqlException: Invalid column name 'Client_ClientId'."

A valid relationship to the Client entity model could not be determined. In our case, there were duplicate virtual references in the Client model (table) to the Document model (table).

The Document model had the following properties:

        public Nullable ClientId { get; set; }
        public virtual Client Client { get; set; }


However, the Client model had the following duplicate properties:

        public virtual ICollection ClientDocuments { get; set; }
        public virtual ICollection Documents { get; set; }

Removal of the duplicate eliminated the exception message.


Saturday, February 18, 2017

Angular2 rollup project errors

Receiving the following error message in the Task Runner Explorer window when rolling up an Angular2 app using Gulp (VisualStudio 2015) 

To fix the following error,
Unhandled promise rejection (rejection id: 1): Error: 'ChartsModule' is not exported by node_modules\ng2-charts\ng2-charts.js
Add the following lines

var charts_module_2 = require('./components/charts/charts');
exports.ChartsModule = charts_module_2.ChartsModule;

Inside of

\node_modules\ng2-charts\ng2-charts.js



To fix the following error,


Unhandled promise rejection (rejection id: 1): Error: 'MapsAPILoader' is not exported by node_modules\angular2-google-maps\core\index.js
Add the following lines:


var core_module_2 = require('./core.umd');
exports.MapsAPILoader = core_module_2.MapsAPILoader;

Inside of

node_modules/angular2-google-maps/core/index.js


For help fixing this error see https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module 



To fix the following error,
Unhandled promise rejection (rejection id: 1): Error: 'FileUploader' is not exported by node_modules\ng2-file-upload\index.js
Add the following lines

var file_uploader_module_2 = require('./components/file-upload/file-uploader.class');
exports.FileUploader = file_uploader_module_2.FileUploader;

Inside of

\ node_modules\ng2-file-upload\ng2-file-upload.js (2.2.1)


Tuesday, January 17, 2017

Angular2 issues with Vaadin Combo box. Using [ngModel] and (selected-item-changed) to set selected id value. not using [(ngModel)] selected-item-changed fires 3 times: 1) with 1st item in list - no matter what selection 2) same value as first 3) null value result: no selection is made. findings: item-value-path has wrong path. selected-item-changed fires 2 times: 1) with correctly selected value 2) null value result: no selection is made. findings: selected-item-changed handler was (re)setting the selected value to an invalid property, resulting in value being null a.selected-item-changed fires 2 times: 1.a) with correctly selected value 2.a) with 1st item in list result: wrong selection is made. b.selected-item-changed fires 2 times: 1.b) with previous selection 2.b) with correct value result: correct selection is made. c.selected-item-changed fires 1 time: 1.c) with correct value findings: item-value-path was using a key that could be null for selected item. selected-item-changed handler was (re)setting the selected value to correct value again, resulting in second change event firing. If key was valid and unique, selection was made correctly.

Wednesday, July 01, 2015

A Remote action is reporting a 'not found' exception.

The remote action is passing an incorrect number of parameters or one of the parameters is NULL. If the signature looks good, it is likely a null reference causing this error. Visualforce.remoting.Manager.invokeAction( 'traction_Page_Controller.submitForm', JSON.stringify(formData), function(result, event) { if (event.type !== 'exception') { console.log(result); } else { console.log('exception *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!'); } } ); Visualforce Remoting Exception: Method 'submitForm' not found on controller traction_Page_Controller. Check spelling, method exists, and/or method is RemoteAction annotated

Tuesday, July 08, 2014

Adding, Removing, Re-Adding SQL accounts

Management Studio
[Server\Instance]>Security>Logins >> Add Login

SQL
SELECT SUSER_SID('<<username>>')

SELECT * FROM sys.server_principals SP where SID = <<user sid>>

Management Studio
[Server\Instance]>Databases>Object>Security>Users>User >> Delete User (Repeat as necessary)

[Server\Instance]>Security>Users>User >> Delete User

SQL
sp_droplogin <<username>>

SELECT SUSER_SID('<<username>>')

SELECT * FROM sys.server_principals SP where SID = <<user sid>>

Management Studio
[Server\Instance]>Security>Logins >> Add Login

Tuesday, March 18, 2014

ASP.Net Site loading slowly. MVC Site loading slowly. WCF service loading slowly. Cannot write to trace/error log files. File path is wrong