Principal End of One2One Map in EntityFramework
##What does principal end of an association means?
In one-to-one relation one end must be principal and second end must be dependent. Principal end is the one which will be inserted first and which can exist without the dependent one. Dependent end is the one which must be inserted after the principal because it has foreign key to the principal.
##How to config in FluentAPI? Say we have one to one User and UserProfile entities, and the User is principal, UserProfile is dependant.
class User{
UserProfile Profile { get;set; }
//...
}
class UserProfile{
User User{ get;set; }
//...
}
Then the fluentAPI configuration will be:
modelBuilder.Entity<User>().HasRequired(u => u.Profile).WithRequiredPrincipal(p => p.User);
Written with StackEdit.
The 'interesting' JavaScript Types
typeof
primitive types
Here lists the typeof
results of primitive types:
var undefinedVariable;
var nullValue = null;
var anObject = new Object();
var func = function () { };
typeof ("string"); //result in "string"
typeof (1024); // number
typeof (true); // boolean
typeof (undefinedVariable); // undefined
typeof (anObject ); // object
typeof (undeclaredValue); // undefined
typeof (nullValue); // object
typeof (null) // object
typeof (func) // function
typeof (Object) // function
Things need to be highlighted are:
- Both
undefined
andundeclared
variable are of typeundefined
- Variable is
null
when assigned with null otherwise it will beundefined
Object
is afunction
null
is anobject
, I guess it means a null object.
Great JavaScript Interview Questions
19 Great JavaScript Interview Questions
copied from here
Namespace
What is the significance of, and reason for, wrapping the entire content of a JavaScript source file in a function block?
A: This is an increasingly common practice, employed by many popular JavaScript libraries (jQuery
, Node.js
, etc.). This technique creates a closure around the entire contents of the file which, perhaps most importantly, creates a private namespace and thereby helps avoid potential name clashes between different JavaScript modules and libraries.
Another feature of this technique is to allow for an easily referenceable (presumably shorter) alias for a global variable. This is often used, for example, in jQuery
plugins. jQuery
allows you to disable the $
reference to the jQuery
namespace, using jQuery.noConflict()
. If this has been done, your code can still use $
employing this closure technique, as follows:
(function($) { /* jQuery plugin code referencing $ */ } )(jQuery);
Get Website URLs via JavaScript
Copied from here
There are several ways you can do this, but one way might be best for certain situations (e.g. within an iFrame).
Protocol + Domain + Page
document.URL
> "http://example.com/page1.html"
document.location.href
> "http://example.com/page1.html"
Protocol + Domain
document.location.origin
> "http://example.com"
Domain
document.location.host
> "example.com"
Page
document.location.pathname
> "/page1.html"
Written with StackEdit.
Using CSS Properties to Create a Cool Button
Using CSS properties alone, recreate this button:
This would be a great test of the candidate’s CSS3 skills. This button is loaded with that kind of stuff. Things I would look for:
- How did they handle multiple borders?
box-shadow
is probably the best way here. - Did they use
text-transform
: uppercase; for the text? That would be best. - How did they handle the stars? Pseudo elements would be a good candidate there. Did they use
unicode
? Icon font? - Did they catch the subtle
text-shadow
? - How did they split the background in the main part of the button? a
linear-gradient
with no fade would be a good technique there. Orbox-shadow
. - Were they careful with the nested
border-radius
?
My solution
a {
border-radius: 4px;
border-color : aliceblue;
background-color: gray;
padding: 5px;
display:inline;
text-decoration: none;
text-transform:uppercase;
box-shadow:0px 0px 1px 4px red,
0px 0px 1px 8px #000000;
text-shadow:1px 1px #00ffff;
font-weight: bold;
background: linear-gradient(180deg, lightgray, gray);
}
a:before, a:after{
content:'\2605';
}
The challenge/question was from here
Written with StackEdit.