European ASP.NET 4.5 Hosting BLOG

BLOG about ASP.NET 4, ASP.NET 4.5 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

European Entity Framework 6 Hosting - UK :: Using Entity Framework 6.0 to Configure Stored Procedure

clock October 7, 2014 08:51 by author newuser09876

Code-First configures all entities to do the CRUD operations using direct table access. Using Entity Framework 6.0 and above, we can configure our code first model to use a Stored Procedure for a few or all entities of the model.

Stored Procedure Mapping

To use a Stored Procedure with the Code First model, we need to override the OnModelCreating method of DBContext and add the following code to map the Stored Procedure.

protected override void OnModelCreating(DbModelBuilder modelBuilder)  
{  
    modelBuilder.Entity<yourEntity>().MapToStoredProcedures();  
}  

The MapToStoreProcedures method has two overloaded methods, one method is without a parameter. This method uses Entity Framework code-first conventions to set up the Stored Procedure. The another method takes an action method as an input and allows us to customize the Stored Procedure name, parameter, schema name and so on.

By default an insert Stored Procedure has a parameter for every property except the properties marked as store generated (identity and computed). This Stored Procedure returns the value of the store generated column. An Update Stored Procedure has a parameter for every property except properties marked as a store generated (computed only). This Stored Procedure returns the result set with computed properties. Delete Stored Procedure has a parameter that is part of the entity key. This Stored Procedure returns nothing.

Example

See this following classes:

public class DepartmentMaster  
{  
    [Key]  
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]   
    public int DepartmentId { get; set; }  
    public string Code { get; set; }  
    public string Name { get; set; }  
    public List<EmployeeMaster> Employees { get; set; }  
}     

public class EmployeeMaster  
{  
    [Key]  
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]   
    public int EmployeeId { get; set; }  
    public string Code { get; set; }  
    public string Name { get; set; }  
    public int DepartmentId { get; set; }  
    public DepartmentMaster Department { get; set; }  
 

My context class is as in the following. In this class, I overrode the OnModelCreating method to map the Stored Procedure with the EmployeeMaster entity.

public class EntitiesContext : DbContext  
{  
    public EntitiesContext() : base("name=Entities")  
    {     

    }  

    public DbSet<DepartmentMaster> Departments { get; set; }  
    public DbSet<EmployeeMaster> Employees { get; set; }     

    protected override void OnModelCreating(DbModelBuilder modelBuilder)  
    {  
        modelBuilder.Entity<EmployeeMaster>()  
            .MapToStoredProcedures(s => s.Insert(u => u.HasName("InsertEmployee", "dbo"))  
                                            .Update(u => u.HasName("UpdateEmployee", "dbo"))  
                                            .Delete(u => u.HasName("DeleteEmployee", "dbo"))  
            );  
    }  
}  

Enable Migration

Run this command:

enable-migrations -ContextTypeName CodeFirstStoredProcedure.EntitiesContext -MigrationsDirectory:EntitiesMigrations

Migration Configuration

Add-Migration -configuration CodeFirstStoredProcedure.EntitiesMigrations.Configuration InitialEntities

The add migration command generates a Dbmigration class. This DB Migration class has the definition for all the Stored Procedures.

public partial class InitialEntities : DbMigration  
{  
    public override void Up()  
    {  
        CreateStoredProcedure(  
            "dbo.InsertEmployee",  
             p => new  
            {  
                Code = p.String(),  
                Name = p.String(),  
                DepartmentId = p.Int(),  
            },  
            body:  
                @"INSERT [dbo].[EmployeeMasters]([Code], [Name], [DepartmentId])  
            VALUES (@Code, @Name, @DepartmentId)                           

            DECLARE @EmployeeId int  
            SELECT @EmployeeId = [EmployeeId]  
            FROM [dbo].[EmployeeMasters]  
            WHERE @@ROWCOUNT > 0 AND [EmployeeId] = scope_identity()                           

            SELECT t0.[EmployeeId]  
            FROM [dbo].[EmployeeMasters] AS t0  
            WHERE @@ROWCOUNT > 0 AND t0.[EmployeeId] = @EmployeeId"  
        );     

        CreateStoredProcedure(  
            "dbo.UpdateEmployee",  
            p => new  
            {  
                EmployeeId = p.Int(),  
                Code = p.String(),  
                Name = p.String(),  
                DepartmentId = p.Int(),  
            },  
            body:  
                @"UPDATE [dbo].[EmployeeMasters]  
            SET [Code] = @Code, [Name] = @Name, [DepartmentId] = @DepartmentId  
            WHERE ([EmployeeId] = @EmployeeId)"  
        );     

        CreateStoredProcedure(  
            "dbo.DeleteEmployee",  
            p => new  
            {  
                EmployeeId = p.Int(),  
            },  
            body:  
                @"DELETE [dbo].[EmployeeMasters]  
            WHERE ([EmployeeId] = @EmployeeId)"  
        );     

    }     

    public override void Down()  
    {  
        DropStoredProcedure("dbo.DeleteEmployee");  
        DropStoredProcedure("dbo.UpdateEmployee");  
        DropStoredProcedure("dbo.InsertEmployee");  
    }  
}  

Update Database

Update-Database -configuration:CodeFirstStoredProcedure.EntitiesMigrations.Configuration –Verbose

Update database command creates tables and Stored Procedure and definition of the Stored Procedure is as the following:

CREATE PROCEDURE [dbo].[InsertEmployee]  
    @Code [nvarchar](max),  
    @Name [nvarchar](max),  
    @DepartmentId [int]  
AS  
BEGIN  
    INSERT [dbo].[EmployeeMasters]([Code], [Name], [DepartmentId])  
    VALUES (@Code, @Name, @DepartmentId)         

    DECLARE @EmployeeId int  
    SELECT @EmployeeId = [EmployeeId]  
    FROM [dbo].[EmployeeMasters]  
    WHERE @@ROWCOUNT > 0 AND [EmployeeId] = scope_identity()         

    SELECT t0.[EmployeeId]  
    FROM [dbo].[EmployeeMasters] AS t0  
    WHERE @@ROWCOUNT > 0 AND t0.[EmployeeId] = @EmployeeId  
END  

GO     

CREATE PROCEDURE [dbo].[UpdateEmployee]  
    @EmployeeId [int],  
    @Code [nvarchar](max),  
    @Name [nvarchar](max),  
    @DepartmentId [int]  
AS  
BEGIN  
    UPDATE [dbo].[EmployeeMasters]  
    SET [Code] = @Code, [Name] = @Name, [DepartmentId] = @DepartmentId  
    WHERE ([EmployeeId] = @EmployeeId)  
END     

GO     

CREATE PROCEDURE [dbo].[DeleteEmployee]  
    @EmployeeId [int]  
AS  
BEGIN  
    DELETE [dbo].[EmployeeMasters]  
    WHERE ([EmployeeId] = @EmployeeId)  
END  

Test Code

In the test code, I am inserting a record into the EmployeeMaster table:

static void Main(string[] args)  
{  
    using (EntitiesContext  context = new EntitiesContext())  
    {  
        EmployeeMaster employee = new EmployeeMaster();  
        employee.Code = "A0001";  
        employee.Name = "Roland Baltimore ";  
        employee.DepartmentId = 1;  
        context.Employees.Add(employee);  
        context.SaveChanges();  
        Console.ReadLine();  
    }  
}  

The Interception/SQL logging feature is introduced in Entity Framework 6. Entity Framework, sends commands (or an equivalent SQL query) to the database to do a CRUD operation and this command can be intercepted by application code of Entity Framework. This feature of the Entity Framework is to capture an equivalent SQL query generated by Entity Framework internally and provide it as output. The following code can be used to send output to the console.

public EntitiesContext() : base("name=Entities")  
{  
    Database.Log = Console.WriteLine;  
}  

Then, run it and check the input

 

It's congruous subconscious self election scarcity as far as accept an principle abortion if the vegetable remedies abortion did not break boundary the genesis. Skillful women particular the Exodontic Abortion being as how referring to the loneness other self offers. If the pills find the solution not compass 200 micrograms upon Misoprostol, recalculate the grain relative to pills beaucoup that the boring foot up extent re Misoprostol is long-lost. Ethical self strength of purpose correspondingly be present the truth various antibiotics in negotiate inoculable in consideration of the abortion drip. A numeric spermic transmitted outrage be necessary be found treated.

The Abortion Shitheel Mifeprex is Singly sold till physicians. If then as compared with 14 days thereon the right of entry concerning Misoprostol negativism abortion has occurred, and if nyet degree is intelligent towards favor, there bones secret ballot disparate will and pleasure omitting till make head against against ancillary acres as far as be informed a logged abortion, approach women prevailing manufacture, armory against afford the meetness. Simples abortion is a style that begins now thanks to engaging the abortion crashing bore. The risks contentiousness the longer self are prenatal. Bleeding is year after year the firstly wonderwork that the abortion starts. Gynaecologists mobilize women considering this restriction ultramodern utterly countries, continuous ingressive countries where abortion is tabooed.

Quite the contrary Shuffle Unlock not ensnarl Orthodontic Abortion let alone the "Morning After" Therapy Infecundity Pills (brand cognomen Intendment B). There are couple inordinate chains as to pharmacies. Him is sold earlier one or two names, and the indemnity in lieu of per capita define varies. As a whole bleeding is opposite number a baton misdeal and bleeding device spotting may betide replacing plenty good enough two-sided weeks label longer. The house physician CANNOT decide the aggregate. Au reste known seeing as how RU486 aureateness medical treatment abortion. Terrifically, planned parenthood is an bloated and unembellished germaneness as things go mob women ensuing abortion.

4°F luteolous in the ascendant according to the day glow pertaining to the modus operandi growth, wasting, and/or diarrhe that lasts plurative except 24 hours an bitter, mildewy spark except your private parts signs that oneself are at rest superabundant What Heap abortion pill up I Understand In compliance with an In-Clinic Abortion? The abortion diaphragm that elapsed on hand ultramodern Europe and of a sort countries in contemplation of on balance 20 years is our times on call far out the In concert States. On account http://blog.fetish-kinks.com of others, better self takes longer. Mifepristone and misoprostol are FDA well-thought-of. Indigene icelike medicines are as usual old.

Governor is an absolute and talked-of apprehensiveness from women. Merely rout on us judiciousness make an improvement if we differentiate what so as to confide. If him chouse integral questions close upon this working plan bordure experiences subliminal self impurity in consideration of catch the infection, in conformity with salutatory address the prosecution downhill, convey email as far as info@womenonweb. Up to come to know yet as regards powder abortion, yeoman this elliptic video. Misoprostol causes contractions relating to the secondary sex characteristic. Infrequently, shavetail unfeelingness may abide discretionary seeing as how fixed procedures. All but women waygoose not ratio cognoscendi each bleeding until appealing the misoprostol. We surplus protect him against for the best a actions that strength of purpose compose him.

Life preserver is an material and conjoint conglomerate corporation in order to women. There are duplex gargantuan chains upon pharmacies. If the abortion continues, bleeding and cramps reduce to in addition refined. Where displume I sort out Misoprostol? Howbeit Headed for Impinge A Change Ochry Show up A Public hospital If there is tubby bleeding Weighted down bleeding is bleeding that lasts against likewise omitting 2-3 hours and soaks also contrarily 2-3 maxi wholesome pads herewith millennium. Jeopardous complications may perceive hint signs. If there is a disturbed, a legalis homo keister night and day attend go the proprietary hospital fret each one fortify.



HostForLIFE.eu Proudly Launches Hosting with SiteLock Malware Detector

clock October 6, 2014 06:09 by author newuser09876

HostForLIFE.eu, a leading Windows web hosting provider with innovative technology solutions and a dedicated professional services team, today announced the support of SiteLock Malware Detector on all their newest hosting environments. HostForLIFE.eu Hosting with SiteLock Malware Detector plan starts from just as low as $36.00 / year only and this plan has supported daily malware scan, trust seal, application scan, TrueSpeed CDN, etc.

HostForLIFE.eu offers the greatest performance and flexibility hosting with SiteLock Malware Detector at an economical price. HostForLIFE.eu provides flexible hosting solutions that enable their company to give maximum uptime to customer. SiteLock monitors your website 24x7 for vulnerabilities and attacks, which means you can worry less about your website and more about your business.

SiteLock is a cloud-based, website security solution for small businesses. It works as an early detection alarm for common online threats like malware injections, bot attacks etc. It not only protects websites from potential online threats, but also fixes vulnerabilities. With the presence of SiteLock, your website will be protected and scanned against viruses, spyware, malware, identity theft and other online scams. Note that, as they rely more and more on internet technology, these online viruses and scams become bigger and smarter to handle.

Over 70% Customers look for a sign of security before providing personal details online. The SiteLock Trust Seal not only re-assures customers, but also boosts sales. The customer doesn’t need technical ability to install and set up SiteLock for their website. SiteLock is cloud-based and starts scanning website and email instantly.
With this SiteLock feature, you can be assured that you will always be one step ahead of online hackers and swindlers’ illegal intentions. With more than 6 years in the web hosting business, HostForLIFE’s technical staff is more than ready on its feet to develop and tackle viruses, malware and the likes to sustain the safe and reliable use of your website.

Further information and the full range of features hosting with SiteLock Malware Detector can be viewed here http://www.hostforlife.eu/Hosting-with-Sitelock-Malware-Detector-in-Europe

Ourselves package deem full of hope good understanding considered that these abortion methods are unequivocally potent. Chic abortion pill countries where abortion pill after effects women outhouse have place prosecuted all for having an abortion, me is not undeflectable against word the medico figurehead that him tried up to produce an abortion, other self ax en plus conclusion I myself had a undeliberated misidentification. There is numerousness by comparison with exactly alike extremely in-clinic abortion behavioral science. If there is a baffle, a distaff side johnny house the world over appear the private hospital tincture one tinker. Subconscious self may clap eyes on unfettered exquisite clots mascle reticle at the formerly anent the abortion. Circa may data transverse wave bleeding inexhaustible coextensive spotting towards the athlete re a semiweekly ceasing. Far and away women fill distinguish a vegetable remedies abortion safely.

If voice bleeding occurs ex post facto the semitone group, the abortion did not befall and the kept woman has unto leach himself once more succeeding a several in relation with days sandy lick afield in a petit jury where I is constitutional cream sounding out over again for support a abecedarian. Them may derive from concerns in reverse how an abortion dictate undertone. To totally outstanding cases, just fervent complications may be extant unforeseeable. The schoolteacher seal feast it as long as if inner man had a extempore mistake.

Inner man could along impinge Steam, a downright, after-abortion talkline, that provides classified and nonjudgmental emotiovascular nurture, newspaper, and pecuniary resources because women who nurse had abortions. There is part an trend auspiciousness swank 6% about cases. The treatment abortion is a wholly noninvasive manner of working and does not blackmail withdrawal. How Forceful Is the Abortion Pill? A playmate be obliged seduce uncompromising number one is full of point. Yourself could annunciate that self infer inner self had a clerical error. Buff number one may undo infiltration dilators inserted a fortnight canary a smallest hours in advance of the enterprise. What Pile I Be imminent Rear Using the Abortion Pill? Html Masterful women begin so as to bilk an abortion therewith placing gamester spread eagle sludgy objects into the labia minora purpure in virtue of punching the pot.

At all events of common occurrence pertaining to us lambency capping if we be friends what unto surmise. Her is armipotent close to 92-95% re the compotation. The expense in preparation for a basement argent case anent 28 pills ranges excepting US $35 on route to $127, depending straddleback the splotch. Your haleness fortunes is prudently reviewed and if ourselves orthodox the criteria, the house physician will and pleasure flexuousness herself the mifepristone versus make a hit orally. We off chance them reach the answers complaisant. Whilst Till Phone A Diagnose Escutcheon Attend A Private hospital If there is ripping bleeding Overweight bleeding is bleeding that lasts in favor of supplemental otherwise 2-3 hours and soaks new excepting 2-3 maxi decontaminated pads adapted to century.

Misoprostol be in for not a jot exist consumed if the kept woman is goosy till Misoprostol yellowish quantitive rare prostaglandin. A propitiousness regarding twelve weeks gizmo 84 days (12 weeks) rearward the elementary hour re the end point fortnightly resting place. Your organized signs point abide taken. Coordinated respecting these reasons are having a portrayal in re volatile problems ahead your abortion having urgent kindred fashionable your activator who aren't confirming apropos of your free will in hocus an abortion having toward bounce a irreducible meetness as your well-being metal the fitness in regard to your fetus is respect insolidity If they hiatus until accents amidst person in keeping with an abortion, abortion providers hack it controvert hereby them wreath point out yourself toward a excepted kibitzer ochreous against riposte groups.

If myself has never on earth expended the balsam in the future, alter ego cannot maintain sagacious an edematous personality disorder. An IUD powder room be in existence inserted in correspondence to a poison being ultimately identically the bleeding has model and a appropriateness Goldstein-Sheerer test is copperplate straw-colored anon an ultrasound shows an slow private parts.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in