Always hated the organizations of your CSS?
Now in Visual Studio there is support for CSS pre-processors.
A CSS pre-processor helps you organize your css, use variables, simplify your code, use multiple files and join them to 1 compiled, minified, css file.
Such a pre-processor is SASS. Easy to use and it's documentation is very clear.
In Visual Studio there is no "out-of-the-box" support for it, but you can install an extension called "Web compiler" for it.
An extra contextmenu item is added for compiling your css and the sass file will be compiled into a normal css and a minified version!
Now in your web project just rename the extension of your css file to .scss and you're good to go.
For me a very important feature is being able to split up the css files and include them via the @import statement.
Experiencing it in a few projects now, i cannot do without them anymore!
vrijdag 12 februari 2016
EF code first, using view for query, st proc for commands
In Entity Framework you define your mapping between a class/ an entity via configuration classes in a modelbuilder.
Let's say you want to say a entity needs to use a view for querying the data and use the table to insert, update or delete the data. In general this is not possible.
Indirectly you can set the table of an entity to the view and use stored procedures for commanding purposes.
For mapping of an entity you inherit EntityTypeConfiguration object to configure you mapping definition. In this class you can define the mapping to the table and also define the stored procedures for insert, update and delete.
For Example:
class PlannableEmployeeConfiguration : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration
{
public PlannableEmployeeConfiguration()
{
ToTable("ResourceEmployee"); //view
HasKey(t => t.Id);
MapToStoredProcedures(m =>
{
m.Delete(delConfig =>
{
delConfig.HasName("PlannableEmployeeDelete");
delConfig.Parameter(pe => pe.Id, "Id");
});
m.Insert(
insertConfig => { insertConfig.HasName("PlannableEmployeeInsert"); }
);
m.Update(
updateConfig => { updateConfig.HasName("PlannableEmployeeUpdate"); }
);
}
);
}
}
Now you can add the configuration to dbBuilder.
dbBuilder.Configurations.Add(new PlannableEmployeeConfiguration());
And generate the stored procedures via the console with "add-migration". In the generated migration file you need to change the stored procedures; Why?
Because in the generated stored procedures the view is used to insert, update or delete the data. This is because you used the view to map with ToTable. Change the sql to use the table and you are good to go to update the database
Hope this will help you for having a seperate query and command using the EF code first principles.
Let's say you want to say a entity needs to use a view for querying the data and use the table to insert, update or delete the data. In general this is not possible.
Indirectly you can set the table of an entity to the view and use stored procedures for commanding purposes.
For mapping of an entity you inherit EntityTypeConfiguration object to configure you mapping definition. In this class you can define the mapping to the table and also define the stored procedures for insert, update and delete.
For Example:
class PlannableEmployeeConfiguration : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration
{
public PlannableEmployeeConfiguration()
{
ToTable("ResourceEmployee"); //view
HasKey(t => t.Id);
MapToStoredProcedures(m =>
{
m.Delete(delConfig =>
{
delConfig.HasName("PlannableEmployeeDelete");
delConfig.Parameter(pe => pe.Id, "Id");
});
m.Insert(
insertConfig => { insertConfig.HasName("PlannableEmployeeInsert"); }
);
m.Update(
updateConfig => { updateConfig.HasName("PlannableEmployeeUpdate"); }
);
}
);
}
}
Now you can add the configuration to dbBuilder.
dbBuilder.Configurations.Add(new PlannableEmployeeConfiguration());
And generate the stored procedures via the console with "add-migration". In the generated migration file you need to change the stored procedures; Why?
Because in the generated stored procedures the view is used to insert, update or delete the data. This is because you used the view to map with ToTable. Change the sql to use the table and you are good to go to update the database
Hope this will help you for having a seperate query and command using the EF code first principles.
Abonneren op:
Posts (Atom)