Spring Data Requery is alternatives of Spring Data JPA
Requery is lightweight ORM for DBMS (MySQL, PostgreSQL, H2, SQLite, Oracle, SQL Server)
Spring Data Requery provide Query By Native Query, Query By Example and Query By Property like Spring Data JPA
Spring Data Requery is better performance than JPA
Ajax is the web's hottest user interface. Struts is Java's most popular web framework. What happens when we put Ajax on Struts?
In this session, we look at writing a new Struts 2 application from square one, using the Yahoo User Interface (YUI) Library on the front end, and Struts 2 on the backend. YUI provides the glitz and the glamour, and Struts 2 provides the dreary business logic, input validation, and text formatting.
During the session, we will cover
* How to integrate an Ajax UI with Struts 2
* Basics of the Yahoo User Interface (YUI) Library
* Business services Struts can provide to an Ajax UI
Who should attend: Ajax developers who would like to utilize Struts as a back-end, and Struts developers who would like to utilize Ajax as a front-end.
To get the most from this session, some familiarity with an Ajax library, like YUI or Dojo, is helpful.
Spring Data Requery is alternatives of Spring Data JPA
Requery is lightweight ORM for DBMS (MySQL, PostgreSQL, H2, SQLite, Oracle, SQL Server)
Spring Data Requery provide Query By Native Query, Query By Example and Query By Property like Spring Data JPA
Spring Data Requery is better performance than JPA
Ajax is the web's hottest user interface. Struts is Java's most popular web framework. What happens when we put Ajax on Struts?
In this session, we look at writing a new Struts 2 application from square one, using the Yahoo User Interface (YUI) Library on the front end, and Struts 2 on the backend. YUI provides the glitz and the glamour, and Struts 2 provides the dreary business logic, input validation, and text formatting.
During the session, we will cover
* How to integrate an Ajax UI with Struts 2
* Basics of the Yahoo User Interface (YUI) Library
* Business services Struts can provide to an Ajax UI
Who should attend: Ajax developers who would like to utilize Struts as a back-end, and Struts developers who would like to utilize Ajax as a front-end.
To get the most from this session, some familiarity with an Ajax library, like YUI or Dojo, is helpful.
Hibernate, created by Gavin King, known as the best and dominated object/relational persistence (ORM) tool for Java developers (Now is support .NET). It provides many elegant and innovative ways to simplifies the relational database handling task in Java.
Hibernate is great at a lot of things, but its something that needs to be used appropriately. In this tutorials, it providing many step by step examples and explanations on using Hibernate3
Xcore is a textual format to define ecore models. This not only makes editing and reading much more convenient but has other cool advantages as well. Xcore, for instance, allows to embed Xbase expressions to define logic within EOperations and the like.
In this session you will learn, why and when using Xcore is a good idea and how to use it with Xtext languages. I will explain talk about which URIs to use, and how to properly configure the MWE2 file as well as more complicated setups, with multiple languages and mixtures of ecore, xcore and generated models.
Hamcrest is a library for creating matchers for usage in unit tests, mocks and UI validation. This talk gives a brief introduction to using and writing Hamcrest matchers.
The topics covered:
* Basic introduction to Hamcrest
* Using Matchers in assertions
* Using Matchers with Mockito
* Writing custom matchers
* Ad-hoc matchers
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
Цель доклада — вдохновить разработчиков на более глубокое изучение возможностей Objective-C Runtime, показать способы исследования системы, воодушевить аудиторию на эксперименты.
В докладе показаны несколько примеров использования Objective-C Runtime для решения нетипичных задач. Первый пример - реализация простого KVO своими руками тремя способами. Вторым примером показана полезность исследования приватных классов. Рассказано, как во время работы программы получить информацию о протянутых IBOutlet и IBAction в xib и storyboard. В каждом примере присутствуют особенности реализации, на которых сделан акцент и показаны варианты решения или обхода.
Static analysis: Around Java in 60 minutesAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
The Guava project contains several of Google’s core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. There will be the slides presenting most useful and interesting features of Guava (v.12) that makes stuff simpler, better and code cleaner. We will cover most of the com.google.common.base.* classes and basic use of functions in collection and Google collections and few other features that are part of Guava and I find them very useful. Some of you will think that there is an overlap with Apache commons – and it’s true, but Guava is built with expectation that there is a Function and a Predicate class as well as various builders which makes it really cool and simple for many use cases.
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMERAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
Hibernate, created by Gavin King, known as the best and dominated object/relational persistence (ORM) tool for Java developers (Now is support .NET). It provides many elegant and innovative ways to simplifies the relational database handling task in Java.
Hibernate is great at a lot of things, but its something that needs to be used appropriately. In this tutorials, it providing many step by step examples and explanations on using Hibernate3
Xcore is a textual format to define ecore models. This not only makes editing and reading much more convenient but has other cool advantages as well. Xcore, for instance, allows to embed Xbase expressions to define logic within EOperations and the like.
In this session you will learn, why and when using Xcore is a good idea and how to use it with Xtext languages. I will explain talk about which URIs to use, and how to properly configure the MWE2 file as well as more complicated setups, with multiple languages and mixtures of ecore, xcore and generated models.
Hamcrest is a library for creating matchers for usage in unit tests, mocks and UI validation. This talk gives a brief introduction to using and writing Hamcrest matchers.
The topics covered:
* Basic introduction to Hamcrest
* Using Matchers in assertions
* Using Matchers with Mockito
* Writing custom matchers
* Ad-hoc matchers
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
Цель доклада — вдохновить разработчиков на более глубокое изучение возможностей Objective-C Runtime, показать способы исследования системы, воодушевить аудиторию на эксперименты.
В докладе показаны несколько примеров использования Objective-C Runtime для решения нетипичных задач. Первый пример - реализация простого KVO своими руками тремя способами. Вторым примером показана полезность исследования приватных классов. Рассказано, как во время работы программы получить информацию о протянутых IBOutlet и IBAction в xib и storyboard. В каждом примере присутствуют особенности реализации, на которых сделан акцент и показаны варианты решения или обхода.
Static analysis: Around Java in 60 minutesAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
The Guava project contains several of Google’s core libraries that we rely on in our Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, string processing, I/O, and so forth. There will be the slides presenting most useful and interesting features of Guava (v.12) that makes stuff simpler, better and code cleaner. We will cover most of the com.google.common.base.* classes and basic use of functions in collection and Google collections and few other features that are part of Guava and I find them very useful. Some of you will think that there is an overlap with Apache commons – and it’s true, but Guava is built with expectation that there is a Function and a Predicate class as well as various builders which makes it really cool and simple for many use cases.
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMERAndrey Karpov
Theory
Code quality (bugs, vulnerabilities)
Methodologies of code protection against defects
Code Review
Static analysis and everything related to it
Tools
Existing tools of static analysis
SonarQube
PVS-Studio for Java what is it?
Several detected examples of code with defects
More about static analysis
Conclusions
Object Relational Mapping with Dapper (Micro ORM)Muhammad Umar
Object relational mapping (ORM) is modern technique used to make incompatible type systems collaborate. Dapper is a micro ORM, specially known for its efficiency and simplicity.
A Scalable, Commodity Data Center Network ArchitectureGunawan Jusuf
A Scalable, Commodity Data Center Network Architecture
source : http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=6&cad=rja&uact=8&ved=0CFUQFjAF&url=http%3A%2F%2Fpages.cs.wisc.edu%2F~akella%2FCS740%2FF08%2FDataCenters.ppt&ei=BVxPVIy_Bse68gWwy4HAAw&usg=AFQjCNGYUB_rhG5dbCNAJyvYrhuZ0L7upg&sig2=yYxOytU7vpT7TT8-qD48CA&bvm=bv.77880786,d.dGc
Vibrant Technologies is headquarted in Mumbai,India.We are the best Hadoop training provider in Navi Mumbai who provides Live Projects to students.We provide Corporate Training also.We are Best Hadoop classes in Mumbai according to our students and corporates
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
In this session we will demonstrate how to design DSLs in C# that expose both typed and dynamic API. The advantage of such hybrid APIs is that they can take advantage of dynamic C# features, but offer a fallback for .NET platforms that lack DLR support and developers not willing to abandon the convenience of compile-time code validation. We will show how to ensure code sharing between typed and dynamic versions, and how to package and publish library files so they can be consumed on variety of .NET platforms, including iOS and Android.
Things I have learned over the years through experience of having to deliver code rapidly, with few defects and maximum functionality. I cover basic coding techniques, automated testing and sometimes I have enough time to review tools and code generation!
Adding a modern twist to legacy web applicationsJeff Durta
Avoid misery of working with legacy code
We will see how you can add independent and isolated components to existing pages; pages that may be difficult to change
React and Flux allow you to make self-contained additions that handle their own data access/persistence
In a world where users have ever higher expectations from the apps they use, having data always available, even when the device is offline has become increasingly important.
In this talk we will go through different ways of saving data on the phone and introduce Realm as a replacement for SQLite and ORM's.
Through an example app it will be demonstrated that thinking "Offline first" not only affects your apps architecture for the better, but also results in happier users.
apidays LIVE Australia 2020 - Building distributed systems on the shoulders o...apidays
apidays LIVE Australia 2020 - Building Business Ecosystems
Building distributed systems on the shoulders of giants
Dasith Wijesiriwardena, Telstra Purple (Readify)
Scalable and Flexible Machine Learning With Scala @ LinkedInVitaly Gordon
The presentation given by Chris Severs and myself at the Bay Area Scala Enthusiasts meetup. http://www.meetup.com/Bay-Area-Scala-Enthusiasts/events/105409962/
Since these presentations were spare time hobby - I've decided to share them :)
Hopefully someone will find them useful.
This part continues 1. part with more design patterns like Command, State, NullObject.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
CyanicLab, an offshore custom software development company based in Sweden,India, Finland, is your go-to partner for startup development and innovative web design solutions. Our expert team specializes in crafting cutting-edge software tailored to meet the unique needs of startups and established enterprises alike. From conceptualization to execution, we offer comprehensive services including web and mobile app development, UI/UX design, and ongoing software maintenance. Ready to elevate your business? Contact CyanicLab today and let us propel your vision to success with our top-notch IT solutions.
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
In this slide, we show the simulation example and the way to compile this solver.
In this solver, the Helmholtz equation can be solved by helmholtzFoam. Also, the Helmholtz equation with uniformly dispersed bubbles can be simulated by helmholtzBubbleFoam.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Listen to the keynote address and hear about the latest developments from Rachana Ananthakrishnan and Ian Foster who review the updates to the Globus Platform and Service, and the relevance of Globus to the scientific community as an automation platform to accelerate scientific discovery.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
2. What is Dapper?
A “micro-ORM” written by these guys…
Sam Saffron Marc Gravell
3. What is an ORM?
From Wikipedia: Object-relational mapping (ORM, O/RM, and O/R mapping) in
computer science is a programming technique for converting data between
incompatible type systems in object-oriented programming languages.
Challenges
There are a variety of difficulties that arise when considering how to match an object
system to a relational database.
An alternative to implementing ORM is use of the native procedural languages provided
with every major database on the market. The Data Access Object (DAO) design pattern
is used to abstract these statements and offer a lightweight object-oriented interface to
the rest of the application
Examples
Entity Framework
NHibernate
4. What is CQ[R]S?
From Wikipedia: Command–query separation (CQS) is a principle
of imperative computer programming. It was devised by Bertrand Meyer as part of
his pioneering work on the Eiffel programming language.
It states that every method should either be a command that performs an action,
or a query that returns data to the caller, but not both. In other words, Asking a
question should not change the answer. More formally, methods should return a
value only if they are referentially transparent and hence possess no side effects.
Offers:
Easier scaling (easy to manage read replicas).
Easier testing (easy to mock out each call explicitly).
I’m using interfaces from NuGet package: Spritely.Cqrs.
The “query” or “command” class is the parameter object (can have zero
properties).
The handler class has the behavior and is what gets mocked during testing.
5. // arrange
var expectedThing = new ThingDataAccessObject() { Id = 0, Values = "Monkey" };
var thingMap = new Dictionary<int, ThingDataAccessObject> {
{ expectedThing.Id, expectedThing } };
var mockGetThingByIdQueryHandler = new
Mock<IQueryHandler<GetThingByIdQuery, ThingDataAccessObject>>();
mockGetThingByIdQueryHandler
.Setup(_ => _.Handle(It.IsAny<GetThingByIdQuery>()))
.Returns<GetThingByIdQuery>(query => thingMap[query.ThingId]);
var service = new ThingWcfService(mockGetThingByIdQueryHandler.Object);
// act
var actualThing = service.GetThing(expectedThing.Id);
// assert
Assert.Equal(expectedThing.ToThingWcfObject().Id, actualThing.Id);
Assert.Equal(expectedThing.ToThingWcfObject().Values, actualThing.Values);
// - make sure we're testing all of the properties
Assert.Equal(2, typeof(ThingWcfObject).GetProperties().Count());
Testing with CQRS
6. Ok, what is Dapper?
From Wikipedia: Dapper was started by Sam Saffron and Marc
Gravell because of the N+1 and other performance issues with Entity
framework. Dapper was written for and is used by Stack Overflow.
Dapper's primary feature is mapping from .NET classes to database tables
(and from CLR data types to SQL data types). Dapper also provides data query
and retrieval facilities.
Dapper is a micro-ORM: it does not offer the full range of features of a full
ORM such as nHibernate or Entity Framework. This is by design. Dapper does
not generate the SQL queries, but only maps the result to Plain Old CLR
Objects (POCOs).
The single class ORM is also available on NuGet.
8. ADO.Net vs. Dapper – First the CQRS Part
public class GetThingByIdQuery : IQuery<ThingDataAccessObject>
{
public int ThingId { get; set; }
}
public class GetThingByIdQueryHandler :
IQueryHandler<GetThingByIdQuery, ThingDataAccessObject>
{
private readonly string connectionString;
public GetThingByIdQueryHandler(string connectionstring)
{
this.connectionString = connectionstring;
}
public ThingDataAccessObject Handle(GetThingByIdQuery query)
{
Basic CQRS…
• Class for params (the ‘Query’)
• Class for behavior (the
‘QueryHandler’)
9. ADO.Net vs. Dapper – What they share
Pretty standard fare…
• Using SQL is a good thing because
you can optimize for the database
engine’s provided advantages.
• Use parameterized SQL to prevent
injection…
ThingDataAccessObject ret = null;
var sqlText = @"SELECT ThingId as [Id],
[Values] as [Values]
FROM Thing
WHERE ThingId = @ThingId";
using (IDbConnection connection = new SqlConnection(this.connectionString))
{
connection.Open();
10. ADO.Net Version
Really not that bad…
• It is a little bit of boiler plate
code though which is a pain
var command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = sqlText;
command.Parameters.Add(new SqlParameter("ThingId", query.ThingId));
using (var reader = command.ExecuteReader())
{
reader.Read();
ret = new ThingDataAccessObject
{
Id = reader.GetInt32(0),
Values = reader.GetString(1)
};
}
11. Dapper Version
This should really sell itself…
• Dapper is just that easy!
ret = connection
.Query<ThingDataAccessObject>(sqlText, query)
.SingleOrDefault();
12. What is AutoMapper?
AutoMapper is a package on Nuget (Id=AutoMapper)
A convention-based object-object mapper.
Uses a fluent configuration API to define an object-object mapping strategy
and uses a convention-based matching algorithm to match up source to
destination values.
Geared towards model projection scenarios to flatten complex object models
to DTOs and other simple objects, whose design is better suited for
serialization, communication, messaging, or simply an anti-corruption layer
between the domain and application layer.
13. So you have this in your world…
• This is normal!
• Don’t ever just use only the
EntityFramework class in all
layers no matter what anyone
tells you!
• These objects are contracts in
their own systems.
public class ThingDatabaseObject
{
public int Id { get; set; }
public string Values { get; set; }
}
public class ThingDataAccessObject
{
public int Id { get; set; }
public string Values { get; set; }
}
public class ThingWcfObject
{
public int Id { get; set; }
public string Values { get; set; }
}
public class ThingRestObject
{
public int Id { get; set; }
public string Values { get; set; }
}
14. So you have this in your world…
• This is actually a pretty high overhead, but historically kind of a necessary evil…
public static ThingDataAccessObject ToDataAccessObject(this ThingDatabaseObject source)
{
return new ThingDataAccessObject { Id = source.Id, Values = source.Values };
}
public static ThingWcfObject ToThingWcfObject(this ThingDataAccessObject source)
{
return new ThingWcfObject { Id = source.Id, Values = source.Values };
}
public static ThingRestObject ToThingRestObject(this ThingDataAccessObject source)
{
return new ThingRestObject { Id = source.Id, Values = source.Values };
}
15. And you aslo have this in your world…
• These tests add to the high overhead…
public class ThingConversionExtensionMethodsTests
{
[Fact]
public static void ToDataAccessObject_InputAllPropsSet_OutputAllPropsMatch()
{
// arrange
var objectIn = new ThingDatabaseObject() { Id = 4, Values = "SomeValues" };
// act
var objectOut = objectIn.ToDataAccessObject();
// assert
Assert.Equal(objectIn.Id, objectOut.Id);
Assert.Equal(objectIn.Values, objectOut.Values);
// - make sure we know all the properties to test
Assert.Equal(2, typeof(ThingDatabaseObject).GetProperties().Count());
Assert.Equal(2, typeof(ThingWcfObject).GetProperties().Count());
}
17. There’s really not much difference…
• There is a little overhead on use with
AutoMapper.
• There is much more overhead with extension
methods to convert.
• The extension method version reads a little
nicer
• The AutoMapper version wins just for speed of
coding…
public class ThingWcfService
{
static ThingWcfService()
{
RunDiagnostics();
}
public static void RunDiagnostics()
{
Mapper.CreateMap<ThingDataAccessObject, ThingWcfObject>();
Mapper.AssertConfigurationIsValid();
}
public ThingWcfObject GetThing(int id)
{
var dao = ThingDataAccess.GetThingById(id);
var extMethodRet = dao.ToThingWcfObject();
var autoMapperRet = Mapper.Map<ThingWcfObject>(dao);
18. What is Fluent Migrator?
A NuGet package that allows you manage your database migrations in .NET
source control with supported tooling.
Modeled after the Ruby style of database migrations.
You need this because otherwise you’re probably in one of these camps:
We just re-script from production because we have no DB source we trust.
We suffer EntityFramework because then we always have DB source checked in.
We have some custom complicated process of keeping alter scripts in a structure.
19. Each Migration is a class
[Migration(Versions.BaseMigrationVersion)]
public class ThingDatabaseInitialMigration : Migration
{
public class Versions
{
public const long BaseMigrationVersion = 0;
}
Create a class like so…
• I use a class to hold the versions used in the
attribute as a convenience.
20. Migrations have Migrate “Up” and “Down”
Perform your database operations…
• The fluent grammar makes it really nice to
declare items, add seed data, remove
unneeded items, and easy to port to other
Database Types.
• Can also just run raw SQL like for creating
StoredProcedures.
public static ThingDatabaseObject SeedData = new ThingDatabaseObject()
{ Id = 0, Values = "Monkey" };
public override void Up()
{
Create.Table("Thing")
.WithColumn("ThingId")
.AsInt32()
.PrimaryKey()
.WithColumn("Values")
.AsString();
Insert.IntoTable("Thing").Row(SeedData);
}
public override void Down()
{
Delete.Table("WorkingTranslate_v1");
}