Short solution for short problems

EF : Guid.ToString() in LINQ Where Statement

It's important to understand LINQ order in order to write correct LINQ statements.

Recently I bumped into this one:

public CRM_OPPORTUNITYCLOSED GetAcceptanceClosed(Guid guid)
 return Context.CRM_OPPORTUNITYCLOSEDSet.FirstOrDefault(o => o.OPPORTUNITY_ID == guid.ToString());

When this was run to the Oracle DB, I got this error:

ORA-00932: inconsistente gegevenstypen: - verwacht, NCLOB gekregen

or in English:

ORA-00932: inconsistent datatypes: expected - got CLOB

So what happened? You would expect that the ToString() was called before EF would go the the DB? In this case NO. It passes the Guid value to the DB and you get the error above.

So do your to string convert before you use the query. 

public CRM_OPPORTUNITYCLOSED GetAcceptanceClosed(string guid)
 return Context.CRM_OPPORTUNITYCLOSEDSet.FirstOrDefault(o => o.OPPORTUNITY_ID == guid);

AngularJS: Authorize app

Ruben of Spikes provides a detailed implementation of using windows authentication to authorize Angular apps. In this case using the UI-router.

Spikes Apps

In my previous post I explained how to set up windows authentication in an Angular application.

In this post I will explain how to implement authorization in the application based on the authenticated user.

I’m starting this post with the code base of the previous post.

Extending the Web API

I’ll extend the API with a new model, AppUser, which will contain the user information that is necessary for Authorization in the application.

Next I will change the WinAuthController. I’m returning an instance of the AppUser object when the user is successfully authenticated.

Typically, you would want to load the information from a database or something. To keep things simple, I’m just returning the domain name and a fixed role.

Extending the Angular application

In the Angular application, I’m moving the AuthenticationService into a separate Angularmodule, which I’m calling ‘debiese.security’. I’ll also add an AuthorizationService

View original post

AngularJS and Windows authentication

We are starting up several Anguar JS (in typescript) projects with an .Net WebAPI2 background. This is really an pleasure to work with, it's like playing with lego when you're 10 years old. Keep building and inventing new things.

One of the things that all applications require is security. Inside our application we can use windows authentication. To set this up was really easy, that is, to set it up for simple GET requests. But with POSTS it gets more tricky. Ruben Biesemans from SPIKES explains this in details here: 

How to implement Windows Authentication in an AngularJS application with a stand-alone Web API

Hope this will help solving this nasty preflight errors.