Reflection in C# Case studies in metaprogramming. torsdag 6 mars 14
|
|
- Gervais Morgan
- 6 years ago
- Views:
Transcription
1 Reflection in C# Case studies in metaprogramming
2 GenericDAO
3 ORM for legacy DB DB with T-SQL Stored Procedures (SP) Apps written in C#, VB.Net and VB6 Domain classes require mapping classes Different SP:s return different sets of data for the same domain objects Related data..
4 1 Domain class - 1 DAO Interface Layer UI Model Service Layer Data Access Layer Domain Model Database
5 1 Domain class - 1 DAO Interface Layer UI Model Service Layer Data Access Layer Domain Model Database
6 1 Domain class - 1 DAO Interface Layer UI Model LoginService login(string user) logout(string user) Service Layer Data Access Layer Domain Model Person firstname lastname employments address PersonDAO getall() get(int id) getbyusername(string username)... SQL query tabulated result sets Database DB
7 1 Domain class - 1 DAO Interface Layer UI Model LoginService login(string user) logout(string user) Service Layer Data Access Layer Domain Model Person firstname lastname employments address PersonDAO getall() get(int id) getbyusername(string username)... SQL query Database tabulated result sets Grade grade date Course code credits teacher students GradeDAO getall() get(int id) getby(string studentname, string coursename)... CourseDAO getall() get(int id) getbyname(string coursename)... DB
8 Related data var people = new PersonDAO().GetAll() Person firstname: "Ola" lastname: "Leifler" employments address null null Person firstname: "Berit" lastname: "Larsson" employments address null null people.selectmany(p => p.employments) Do we know if employments have been fetched? What if we only want to make one DB call? (Select 1+N Problem)
9 Legacy support Person firstname lastname employments address PersonDAO getall() get(int id) getbyemployment(int id) getwithaddress(int id) "getall" DB fname: "Ola" lname: "Leifler" fname: "Berit" lname: "Jansson" PersonDAO getall() get(int id) getbyemployment(int id) getwithaddress(int id) "getwithaddress" DB firstname: "Ola" llastname: "Leifler" streetaddress: "Storgatan 1" city: "Linköping"
10 Legacy support Person firstname lastname employments address PersonDAO getall() get(int id) getbyemployment(int id) getwithaddress(int id) "getall" DB fname: "Ola" lname: "Leifler" fname: "Berit" lname: "Jansson" PersonDAO getall() get(int id) getbyemployment(int id) getwithaddress(int id) "getwithaddress" DB firstname: "Ola" llastname: "Leifler" streetaddress: "Storgatan 1" city: "Linköping"
11 Legacy support Person firstname lastname employments address PersonDAO getall() get(int id) getbyemployment(int id) getwithaddress(int id) "getall" DB Address streetaddress city fname: "Ola" lname: "Leifler" fname: "Berit" lname: "Jansson" PersonDAO getall() get(int id) getbyemployment(int id) getwithaddress(int id) "getwithaddress" DB firstname: "Ola" llastname: "Leifler" streetaddress: "Storgatan 1" city: "Linköping"
12 Solution 1 Generic Data Access Object class Dynamic name resolution of Stored Procedures Generated proxy classes for lazy loading Markup and configuration to configure loading related objects, and mapping between data fields and class properties
13 1 Generic DAO var people = GenericDAO<Domain.Person>.Get("GetPeopleByRole", new { RoleId = 3 ); people.should().notbeempty();
14 1 Generic DAO var people = GenericDAO<Domain.Person>.Get("GetPeopleByRole", new { RoleId = 3 ); people.should().notbeempty(); private static ICollection<T> GetEntities(string procedurename,object parameterobject, int limit) { int recordsread=0; var config=getconfig(procedurename); IList<T> entities=new ConcurrentList<T>(); try { using(dbcommand command=buildcommand(procedurename,parameterobject)) { using(idatareader reader=command.executereader()) { var fieldnames=reader.names(); config.init(command,fieldnames); var allfieldsused=config.getallfieldsusedby(reader); if((config.policy& GenericDAO.ExceptionPolicy.AbortOnFieldsUnused)!=0&&!fieldNames.IsSubSetOf(allFieldsUsed)) { // Abort if some SQL result fields are unused throw new FieldsUnusedFromQueryException(fieldNames.Except(allFieldsUsed)); // Add a mapping from the SP to the properties it can set on the current object while(reader.read()&&++recordsread<limit) { entities.add(config.injectfrom(reader)); entities=config.process(entities); finally { DBAccess.CloseConnection(); return entities;
15 1 Generic DAO var people = GenericDAO<Domain.Person>.Get("GetPeopleByRole", new { RoleId = 3 ); people.should().notbeempty(); private static ICollection<T> GetEntities(string procedurename,object parameterobject, int limit) { int recordsread=0; var config=getconfig(procedurename); IList<T> entities=new ConcurrentList<T>(); try { using(dbcommand command=buildcommand(procedurename,parameterobject)) { using(idatareader reader=command.executereader()) { var fieldnames=reader.names(); config.init(command,fieldnames); var allfieldsused=config.getallfieldsusedby(reader); if((config.policy& GenericDAO.ExceptionPolicy.AbortOnFieldsUnused)!=0&&!fieldNames.IsSubSetOf(allFieldsUsed)) { // Abort if some SQL result fields are unused throw new FieldsUnusedFromQueryException(fieldNames.Except(allFieldsUsed)); // Add a mapping from the SP to the properties it can set on the current object while(reader.read()&&++recordsread<limit) { entities.add(config.injectfrom(reader)); entities=config.process(entities); finally { DBAccess.CloseConnection(); return entities;
16 1 Generic DAO var people = GenericDAO<Domain.Person>.Get("GetPeopleByRole", new { RoleId = 3 ); people.should().notbeempty(); private static ICollection<T> GetEntities(string procedurename,object parameterobject, int limit) { int recordsread=0; var config=getconfig(procedurename); IList<T> entities=new ConcurrentList<T>(); try { using(dbcommand command=buildcommand(procedurename,parameterobject)) { using(idatareader reader=command.executereader()) { var fieldnames=reader.names(); config.init(command,fieldnames); var allfieldsused=config.getallfieldsusedby(reader); if((config.policy& GenericDAO.ExceptionPolicy.AbortOnFieldsUnused)!=0&&!fieldNames.IsSubSetOf(allFieldsUsed)) { // Abort if some SQL result fields are unused throw new FieldsUnusedFromQueryException(fieldNames.Except(allFieldsUsed)); // Add a mapping from the SP to the properties it can set on the current object while(reader.read()&&++recordsread<limit) { entities.add(config.injectfrom(reader)); entities=config.process(entities); finally { DBAccess.CloseConnection(); return entities;
17 Dynamic name resolution
18 Dynamic name resolution GetAll() GetPeopleByRole() x 500
19 Dynamic name resolution GetAll() GetPeopleByRole() x 500 GetAll GetPeopleByRole x 500
20 Dynamic name resolution GetAll() GetPeopleByRole() x 500 GetAll GetPeopleByRole x 500
21 Dynamic name resolution using System; using System.Collections.Generic; using System.Linq; using System.Dynamic; using Configuration; using Extensions; GetAll() GetPeopleByRole() x 500 GetAll GetPeopleByRole x 500 namespace Core { public class Dispatcher<T>:DynamicObject where T:class, new() { [... ] public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { string procedurename=binder.name; object paramobj=getparameterobject(binder,args); string storedprocedurename=genericdao<t>.storedprocedurefullname(procedurename); if(procedurename.startswith("get")) { result=getresult(paramobj,storedprocedurename); [... ]
22 Dynamic name resolution using System; using System.Collections.Generic; using System.Linq; using System.Dynamic; using Configuration; using Extensions; GetAll() GetPeopleByRole() x 500 GetAll GetPeopleByRole x 500 namespace Core { public class Dispatcher<T>:DynamicObject where T:class, new() { [... ] public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { string procedurename=binder.name; object paramobj=getparameterobject(binder,args); string storedprocedurename=genericdao<t>.storedprocedurefullname(procedurename); if(procedurename.startswith("get")) { result=getresult(paramobj,storedprocedurename); [... ]
23 Dynamic name resolution using System; using System.Collections.Generic; using System.Linq; using System.Dynamic; using Configuration; using Extensions; GetAll() GetPeopleByRole() x 500 GetAll GetPeopleByRole x 500 namespace Core { public class Dispatcher<T>:DynamicObject where T:class, new() { [... ] public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { string procedurename=binder.name; object paramobj=getparameterobject(binder,args); string storedprocedurename=genericdao<t>.storedprocedurefullname(procedurename); if(procedurename.startswith("get")) { result=getresult(paramobj,storedprocedurename); [... ] dynamic dao = GenericDAO<Domain.Person>.Dispatch(); IEnumerable<Domain.Person> people = dao.getpeoplebyrole(roleid: 3); people.should().notbeempty();
24 Dynamic name resolution using System; using System.Collections.Generic; using System.Linq; using System.Dynamic; using Configuration; using Extensions; GetAll() GetPeopleByRole() x 500 GetAll GetPeopleByRole x 500 namespace Core { public class Dispatcher<T>:DynamicObject where T:class, new() { [... ] public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { string procedurename=binder.name; object paramobj=getparameterobject(binder,args); string storedprocedurename=genericdao<t>.storedprocedurefullname(procedurename); if(procedurename.startswith("get")) { result=getresult(paramobj,storedprocedurename); [... ] dynamic dao = GenericDAO<Domain.Person>.Dispatch(); IEnumerable<Domain.Person> people = dao.getpeoplebyrole(roleid: 3); people.should().notbeempty();
25 Generated proxy classes protected internal T CreateObject<T>(IDataReader reader, IEnumerable<string> allowedfields=null) where T:class, new() { T proxy=proxygenerator.createclassproxy<t>(proxygenerationoptions, new LazyLoadingInterceptor<T>()); foreach(var fieldandproperty in GetFieldsToPropertiesMap<T>(reader, allowedfields)) { var value=getvalue(reader[fieldandproperty.key], fieldandproperty.value); if(value!=null) { GetSetter(fieldAndProperty.Value)(proxy, value); return proxy;
26 Generated proxy classes protected internal T CreateObject<T>(IDataReader reader, IEnumerable<string> allowedfields=null) where T:class, new() { T proxy=proxygenerator.createclassproxy<t>(proxygenerationoptions, new LazyLoadingInterceptor<T>()); foreach(var fieldandproperty in GetFieldsToPropertiesMap<T>(reader, allowedfields)) { var value=getvalue(reader[fieldandproperty.key], fieldandproperty.value); if(value!=null) { GetSetter(fieldAndProperty.Value)(proxy, value); return proxy;
27 Generated proxy classes namespace Support { public class LazyLoadingInterceptor<T>:BaseInterceptor,IInterceptor where T:class, new() { [... ] public void Intercept(IInvocation invocation) { object proxy=invocation.proxy; // Get the target property access method var target=invocation.methodinvocationtarget; string propertyname=getpropertyname(target.name); if(target.name.startswith("get_")) { if(!ispropertyloaded(propertyname)) { // Ignore the returned enumeration of elements from Prefetcher<T> as it is just the original sequence with properties set Prefetcher<T>.FetchRelatedProperty(new List<T>() { proxy as T,typeof(T).GetProperty(propertyName)); SetPropertyLoaded(propertyName); else { // Setter invocation: update "property loaded" map with indication of whether non-default value set var settervalue=invocation.getargumentvalue(0); SetPropertyLoaded(propertyName,setterValue!=setterValue.GetType().DefaultValue()); invocation.proceed();
28 Generated proxy classes namespace Support { public class LazyLoadingInterceptor<T>:BaseInterceptor,IInterceptor where T:class, new() { [... ] public void Intercept(IInvocation invocation) { object proxy=invocation.proxy; // Get the target property access method var target=invocation.methodinvocationtarget; string propertyname=getpropertyname(target.name); if(target.name.startswith("get_")) { if(!ispropertyloaded(propertyname)) { // Ignore the returned enumeration of elements from Prefetcher<T> as it is just the original sequence with properties set Prefetcher<T>.FetchRelatedProperty(new List<T>() { proxy as T,typeof(T).GetProperty(propertyName)); SetPropertyLoaded(propertyName); else { // Setter invocation: update "property loaded" map with indication of whether non-default value set var settervalue=invocation.getargumentvalue(0); SetPropertyLoaded(propertyName,setterValue!=setterValue.GetType().DefaultValue()); invocation.proceed(); Intercept dynamically intercepts method invocations so that properties that are not loaded are fetched from the database
29 Markup and configuration " " public String Name { get; set; " " public String Age { get; set; " " [SP("emp_GetEmployment")] " " [ForeignKey("PersonId")] " " public virtual ICollection<Employment> Employments { get; set;
30 Markup and configuration " " public String Name { get; set; " " public String Age { get; set; " " [SP("emp_GetEmployment")] " " [ForeignKey("PersonId")] " " public virtual ICollection<Employment> Employments { get; set;
31 Markup and configuration " " public String Name { get; set; " " public String Age { get; set; " " [SP("emp_GetEmployment")] " " [ForeignKey("PersonId")] " " public virtual ICollection<Employment> Employments { get; set;
32 Markup and configuration " " public String Name { get; set; " " public String Age { get; set; " " [SP("emp_GetEmployment")] " " [ForeignKey("PersonId")] " " public virtual ICollection<Employment> Employments { get; set;
33 Markup and configuration GenericDAO<Person>.Configure("per_GetPeopleWithAddress").By(x => { x.scanforrelatedtypes(genericdao.fetchrelatedobjectspolicy.scanfields); ); Scan result set for field names that match properties of related objects
34 Markup and configuration GenericDAO<Person>.Configure("GetPeopleByRole").By(x => { x.map("perid").to(p => p.id); x.include<contactinfo>().by(y => { y.map("contactprivateid").to(c => c.id); y.map("privatemobile").to(c => c.mobile); y.map("private ").to(c => c. ); y.through(p => p.privatecontact); ); x.include<contactinfo>().by(y => { y.map("contactcompanyid").to(c => c.id); y.map("companymobile").to(c => c.mobile); y.map("company ").to(c => c. ); y.through(p => p.companycontact); ); x.include<address>(); ); Map each row in the result set to a main Person object, 2x ContactInfo and an Address
35 Markup and configuration per_getpersonsbyrole()
36 Markup and configuration per_getpersonsbyrole() PerId ContactPrivateId PrivateMobile Private ContactCompanyId CompanyMobile Company john@apple.com apple@john.com Id StreetAddress City 20 1 Infinite loop Götene
37 Markup and configuration per_getpersonsbyrole() PerId ContactPrivateId PrivateMobile Private ContactCompanyId CompanyMobile Company john@apple.com apple@john.com Id StreetAddress City 20 1 Infinite loop Götene Person Id: 3 PrivateContact CompanyContact Address ContactInfo Id:14 Mobile: " " "john@apple.com" ContactInfo Id: 15 Mobile: " " "apple@john.com" Address Id: 20 StreetAddress: "1 Infinite loop" City: "Götene"
38 Markup and configuration per_getpersonsbyrole() PerId ContactPrivateId PrivateMobile Private ContactCompanyId CompanyMobile Company john@apple.com apple@john.com Id StreetAddress City 20 1 Infinite loop Götene Person Id: 3 PrivateContact CompanyContact Address ContactInfo Id:14 Mobile: " " "john@apple.com" ContactInfo Id: 15 Mobile: " " "apple@john.com" Address Id: 20 StreetAddress: "1 Infinite loop" City: "Götene"
39 Markup and configuration y.map("contactcompanyid").to(c => c.id);
40 Markup and configuration y.map("contactcompanyid").to(c => c.id); public void To<T1>(Expression<Func<T,T1>> propertyselector) { var selectorexpression = (MemberExpression) propertyselector.body; var prop = (PropertyInfo) selectorexpression.member; Configurator.CustomFieldsToPropertiesMap[FieldName]=prop;
41 Markup and configuration y.map("contactcompanyid").to(c => c.id); public void To<T1>(Expression<Func<T,T1>> propertyselector) { var selectorexpression = (MemberExpression) propertyselector.body; var prop = (PropertyInfo) selectorexpression.member; Configurator.CustomFieldsToPropertiesMap[FieldName]=prop; FieldName is the name of the field returned in the result set (ContactCompanyId)
42
43 Expression Generation
44 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp );
45 Return an expression tree that accepts T and returns a boolean public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp );
46 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Node that refers to the parameter x Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp );
47 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); Node that refers to the constant false return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp );
48 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp ); x == arg
49 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp ); for all values of arg in args
50 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp ); combined with (OrElse)
51 public Expression<Func<T,Boolean>> CreateFilterExpression<T>(params T[] args) { var x = "x"; var paramexp = Expression.Parameter(typeof(T), x); Expression t = Expression.Constant(false); return Expression.Lambda<Func<T,Boolean>>(args.Aggregate(t, " " " " " " " (expr, arg) => " " " " " " " Expression.OrElse(Expression.Equal(paramExp, Expression.Constant(arg)), " " " " " " " " " expr)), " " " " " new ParameterExpression[] { paramexp );
52
53
TDDB84: Lecture 09. SOLID, Language design, Summary. fredag 11 oktober 13
TDDB84: Lecture 09 SOLID, Language design, Summary SOLID Single responsibility principle Open/closed principle Liskov substitution principle Interface segregation principle Depency inversion principle
More informationTDDB84: Lecture 5. Singleton, Builder, Proxy, Mediator. fredag 27 september 13
TDDB84: Lecture 5 Singleton, Builder, Proxy, Mediator Creational Abstract Factory Singleton Builder Structural Composite Proxy Bridge Adapter Template method Behavioral Iterator Mediator Chain of responsibility
More informationPASS4TEST IT 인증시험덤프전문사이트
PASS4TEST IT 인증시험덤프전문사이트 http://www.pass4test.net 일년동안무료업데이트 Exam : 1z0-809 Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z0-809 Exam's Question and Answers 1 from
More informationDatabase Management Systems. Chapter 5
Database Management Systems Chapter 5 SQL Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for the Reserves relation contained only the attributes
More informationMainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.
APPENDIX 1 TABLE DETAILS Mainly three tables namely Teacher, Student and Class for small database of a school are used. The snapshots of all three tables are shown below. Details of Class table are shown
More informationCOMP 430 Intro. to Database Systems. SQL from application code
COMP 430 Intro. to Database Systems SQL from application code Some issues How to connect to database Where, what type, user credentials, How to send SQL commands How to get communicate data to/from DB
More informationCS 327E Class 3. February 11, 2019
CS 327E Class 3 February 11, 2019 1) A join is used to concatenate rows from two tables that are related via referential integrity. For example, joining T and U on T.b and U.b produces V when projecting
More informationCALCULATOR APPLICATION
CALCULATOR APPLICATION Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
More informationDatabase Management Systems. Chapter 5
Database Management Systems Chapter 5 SQL Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for the Reserves relation contained only the attributes
More informationPart I: Short Answer (6 questions, 18 points total)
CSE 143 Sp01 Midterm 2 Sample Solution page 1 of 7 Part I: Short Answer (6 questions, 18 points total) Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space
More informationEGCI 321: Database Systems. Dr. Tanasanee Phienthrakul
1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational
More informationObject-Relational Mapping
Object-Relational Mapping Object-Relational Mapping Software Architecture ORM Problems ORM Solutions Demo Software Architecture Part 1 Architecture Separation of Concerns A design principle that comprises
More informationRepository Pattern and Unit of Work with Entity Framework
Repository Pattern and Unit of Work with Entity Framework Repository pattern is used to create an abstraction layer between the data access layer and the business logic layer. This abstraction layer contains
More information1 of 6 11/08/2011 10:14 AM 1. Introduction 1.1. Project/Component Working Name: SJSAS 9.1, Support for JDBC 4.0 in JDBC RA, RFEs 1.2. Name(s) and e-mail address of Document Author(s)/Supplier: Jagadish
More informationCSC343 Fall 2007 Assignment 2 SQL and Embedded SQL
CSC343 Fall 2007 Assignment 2 SQL and Embedded SQL Distribution date: Friday, October 26, 2007 Due date: Monday, November 12, 2007 1:00 p.m. Instructions 1. Read this assignment thoroughly before you proceed.
More informationTDDD05: Application frameworks
TDDD05: Application frameworks Ola Leifler, IDA, Linköpings universitet Component frameworks A component framework is a software entity that supports components conforming to certain standards and allows
More informationAnswer ALL Questions. Each Question carries ONE Mark.
SECTION A (10 MARKS) Answer ALL Questions. Each Question carries ONE Mark. 1 (a) Choose the correct answer: (5 Marks) i. Which of the following is not a valid primitive type : a. char b. double c. int
More informationCSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige
CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft
More informationThis paper describes how an object-oriented database can be used to support a web site built with Java technology.
USING AN OBJECT-ORIENTED DATABASE TO SUPPORT A WEB APPLICATION BUILT WITH JAVA TECHNOLOGIES Charles R. Moen, M.S. University of Houston - Clear Lake crmoen@juno.com ABSTRACT Morris M. Liaw, Ph.D. University
More informationEfficient Object-Relational Mapping for JAVA and J2EE Applications or the impact of J2EE on RDB. Marc Stampfli Oracle Software (Switzerland) Ltd.
Efficient Object-Relational Mapping for JAVA and J2EE Applications or the impact of J2EE on RDB Marc Stampfli Oracle Software (Switzerland) Ltd. Underestimation According to customers about 20-50% percent
More informationObject Persistence and Object-Relational Mapping. James Brucker
Object Persistence and Object-Relational Mapping James Brucker Goal Applications need to save data to persistent storage. Persistent storage can be database, directory service, XML files, spreadsheet,...
More informationCMPT 354: Database System I. Lecture 2. Relational Model
CMPT 354: Database System I Lecture 2. Relational Model 1 Outline An overview of data models Basics of the Relational Model Define a relational schema in SQL 2 Outline An overview of data models Basics
More informationVisual C# 2012 How to Program by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d.
Visual C# 2012 How to Program 1 99 2-20 14 by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d. 1992-2014 by Pearson Education, Inc. All 1992-2014 by Pearson Education, Inc. All Although commonly
More informationStorage Tier. Mendel Rosenblum. CS142 Lecture Notes - Database.js
Storage Tier Mendel Rosenblum.js Web Application Architecture Web Browser Web Server Storage System HTTP Internet LAN 2 Web App Storage System Properties Always available - Fetch correct app data, store
More information1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material,
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management
More informationPrevious C# Releases. C# 3.0 Language Features. C# 3.0 Features. C# 3.0 Orcas. Local Variables. Language Integrated Query 3/23/2007
Previous C# Releases C# 3.0 Language Features C# Programming March 12, 2007 1.0 2001 1.1 2003 2.0 2005 Generics Anonymous methods Iterators with yield Static classes Covariance and contravariance for delegate
More informationOracle 11g Invisible Indexes Inderpal S. Johal. Inderpal S. Johal, Data Softech Inc.
ORACLE 11G INVISIBLE INDEXES Inderpal S. Johal, Data Softech Inc. INTRODUCTION In this document we will work on another Oracle 11g interesting feature called Invisible Indexes. This will be very helpful
More information3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key
Unit 3: Types of Keys & Data Integrity 3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key Different Types of SQL Keys A key is a single or combination of multiple fields in a
More informationProject Overview and Scope
Project Overview and Scope MISSION What problem does this project address? Historically, students tend to skip class. This system aids instructors in tracking the attendance of their students. It will
More informationPrivate Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH
Private Institute of Aga 2018 NETWORK DATABASE LECTURER NIYAZ M. SALIH Data Definition Language (DDL): String data Types: Data Types CHAR(size) NCHAR(size) VARCHAR2(size) Description A fixed-length character
More informationData Modelling and Databases. Exercise Session 7: Integrity Constraints
Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling
More informationSQL. A C P K Siriwardhana MSc, BSc in Computer Science FIRST COURSE
SQL A C P K Siriwardhana MSc, BSc in Computer Science FIRST COURSE Organizing Data New Perspectives on Microsoft Office 2007: Windows Edition 2 Databases and Relationships A collection of related tables
More informationCOMP519: Web Programming Autumn 2015
COMP519: Web Programming Autumn 2015 In the next lectures you will learn What is SQL How to access mysql database How to create a basic mysql database How to use some basic queries How to use PHP and mysql
More informationVisual Studio 2010 Testing
Visual Studio 2010 Testing Labs Page 1 of 88 Visual Studio 2010 Testing By Benjamin Day Copyright 2013 Benjamin Day Consulting, Inc. www.benday.com Visual Studio 2010 Testing Labs Page 2 of 88 Contents
More informationCOMP 430 Intro. to Database Systems. Encapsulating SQL code
COMP 430 Intro. to Database Systems Encapsulating SQL code Want to bundle SQL into code blocks Like in every other language Encapsulation Abstraction Code reuse Maintenance DB- or application-level? DB:
More informationCS/ENGRD 2110 FALL Lecture 5: Local vars; Inside-out rule; constructors
1 CS/ENGRD 2110 FALL 2018 Lecture 5: Local vars; Inside-out rule; constructors http://courses.cs.cornell.edu/cs2110 Announcements 2 A1 is due tomorrow If you are working with a partner: form a group on
More informationKing Fahd University of Petroleum and Minerals
1 King Fahd University of Petroleum and Minerals Information and Computer Science Department ICS 334: Database Systems Semester 041 Major Exam 1 18% ID: Name: Section: Grades Section Max Scored A 5 B 25
More informationHow does Metaprogramming affect software flexibility in Object-Relational Mapping
How does Metaprogramming affect software flexibility in Object-Relational Mapping Abstract Metaprogramming is an important element in object-relational mapping. It is integrated, because we need to analyze
More informationSpring 2016 Programming Languages Qualifying Exam
This is a closed book test. Clear, correct and concise responses will receive the best mark. Correct, clear and precise answers receive full marks Please start a new page for each question. 1 P a g e 1.
More informationJordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A
Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A Name: ID#: Section #: Day & Time: Instructor: Answer all questions as indicated. Closed book/closed
More informationName of Experiment: Student Database
Name of Experiment: Student Database Exp No: DB1 Background: Student should have basic knowledge of C#. Summary: DBMS is a necessary requirement for any Mobile Application. We need to store and retrieve
More informationCSE143 Summer 2008 Final Exam Part B KEY August 22, 2008
CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008 Name : Section (eg. AA) : TA : This is an open-book/open-note exam. Space is provided for your answers. Use the backs of pages if necessary. The
More informationWorking with Databases and Java
Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured
More informationScore. 1 (10) 2 (10) 3 (8) 4 (13) 5 (9) Total (50)
Student number: Signature: UNIVERSITY OF VICTORIA Faculty of Engineering Department of Computer Science CSC 370 (Database Systems) Instructor: Daniel M. German Midterm 18 June 2003 Duration: 75 minutes
More informationCVC4 - the SMT Solver
CVC4 - the SMT Solver Installation on Linux #install make, for example: apt-get install build-essential #install libgmp, for example: apt-get install libgmp-dev #install boost, for example: apt-get install
More informationCS 2340 Objects and Design - Scala
CS 2340 Objects and Design - Scala Objects and Operators Christopher Simpkins chris.simpkins@gatech.edu Chris Simpkins (Georgia Tech) CS 2340 Objects and Design - Scala Objects and Operators 1 / 13 Classes
More informationQuerying In-Memory Data by Using Query Expressions
Chapter 21 Querying In-Memory Data by Using Query Expressions LINQ (Language Integrated Query) CUSTOMER CID FName Lname Company 1 Ram Kumar CITech 2 Sam Peter HP 3 Anil Kumar EMC 2 4 Anuj Patil Dell 5
More informationDatabase Management Systems,
Database Management Systems SQL Query Language (1) 1 Topics Introduction SQL History Domain Definition Elementary Domains User-defined Domains Creating Tables Constraint Definition INSERT Query SELECT
More informationCreating SDK plugins
Creating SDK plugins 1. Introduction... 3 2. Architecture... 4 3. SDK plugins... 5 4. Creating plugins from a template in Visual Studio... 6 5. Creating custom action... 9 6. Example of custom action...10
More informationJava Persistence API (JPA) Entities
Java Persistence API (JPA) Entities JPA Entities JPA Entity is simple (POJO) Java class satisfying requirements of JavaBeans specification Setters and getters must conform to strict form Every entity must
More informationChapter 5: Physical Database Design. Designing Physical Files
Chapter 5: Physical Database Design Designing Physical Files Technique for physically arranging records of a file on secondary storage File Organizations Sequential (Fig. 5-7a): the most efficient with
More informationIntegrating Solr in JEE Applications. Chris Male Apache Solr / Lucene Committer /
Integrating Solr in JEE Applications Chris Male Apache Solr / Lucene Committer chris@jteam.nl / chrism@apache.org Agenda SolrJ in Action Lessons from Databases Typed Schemas Typed Queries / Responses Document
More informationSQLite Database. References. Overview. Structured Databases
SQLite Database References Android Developers Article https://developer.android.com/training/basics/data-storage/databases.html Android SQLite Package Reference https://developer.android.com/reference/android/database/sqlite/package-summary.html
More informationDiscuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity
Objectives Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Setting Up JDBC Before you can begin to utilize JDBC, you must
More informationPainless Persistence. Some guidelines for creating persistent Java applications that work
Painless Persistence Some guidelines for creating persistent Java applications that work The Authors Anthony Patricio Senior JBoss Certification Developer Highest volume poster on early Hibernate forums
More informationGuidelines Quick Reference
Guidelines Quick Reference.NET Guidelines General Casing Identifier Case Example Class Pascal MyClass Property Pascal BackColor Private fields (class) _Camel _fieldname Private fields (function) Camel
More informationCS18000: Problem Solving And Object-Oriented Programming
CS18000: Problem Solving And Object-Oriented Programming Class (and Program) Structure 31 January 2011 Prof. Chris Clifton Classes and Objects Set of real or virtual objects Represent Template in Java
More informationACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)
ACS-3902 Fall 2016 Ron McFadyen 3D21 ron.mcfadyen@acs.uwinnipeg.ca Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition) 1 The Relational Data Model and Relational Database Constraints
More informationKotlin for Android developers
ROME - APRIL 13/14 2018 Kotlin for Android developers Victor Kropp, JetBrains @kropp Kotlin on JVM + Android JS In development: Kotlin/Native ios/macos/windows/linux Links Kotlin https://kotlinlang.org
More informationFundamentals of Database Systems
Fundamentals of Database Systems Assignment: 1 Due Date: 8th August, 2017 Instructions This question paper contains 15 questions in 5 pages. Q1: The users are allowed to access different parts of data
More informationVisual Basic/C# Programming (330)
Page 1 of 12 Visual Basic/C# Programming (330) REGIONAL 2017 Production Portion: Program 1: Calendar Analysis (400 points) TOTAL POINTS (400 points) Judge/Graders: Please double check and verify all scores
More informationSecond Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010
Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will
More informationPrinciples of Data Management
Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what
More informationVS2010 C# Programming - DB intro 1
VS2010 C# Programming - DB intro 1 Topics Database Relational - linked tables SQL ADO.NET objects Referencing Data Using the Wizard Displaying data 1 VS2010 C# Programming - DB intro 2 Database A collection
More informationAdvanced Programming C# Lecture 11 part 2. dr inż. Małgorzata Janik
Advanced Programming C# Lecture 11 part 2 dr inż. Małgorzata Janik malgorzata.janik@pw.edu.pl Winter Semester 2018/2019 LINQ (part 2) LINQ Previous lecture... 3 / 24 LINQ to SQL Architecture of LINQ to
More informationDatabase Languages. A DBMS provides two types of languages: Language for accessing & manipulating the data. Language for defining a database schema
SQL 1 Database Languages A DBMS provides two types of languages: DDL Data Definition Language Language for defining a database schema DML Data Manipulation Language Language for accessing & manipulating
More informationCOE318 Lecture Notes Week 10 (Nov 7, 2011)
COE318 Software Systems Lecture Notes: Week 10 1 of 5 COE318 Lecture Notes Week 10 (Nov 7, 2011) Topics More about exceptions References Head First Java: Chapter 11 (Risky Behavior) The Java Tutorial:
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a
More informationData Base Lab. The Microsoft SQL Server Management Studio Part-3- By :Eng.Alaa I.Haniy.
Data Base Lab Islamic University Gaza Engineering Faculty Computer Department Lab -5- The Microsoft SQL Server Management Studio Part-3- By :Eng.Alaa I.Haniy. SQL Constraints Constraints are used to limit
More informationConfiguration Web Services for.net Framework
Cloud Contact Center Software Configuration Web Services for.net Framework Programmer s Guide October 2014 This guide describes how to create a client for the Configuration Web Services with the.net framework
More informationUMBC CMSC 331 Final Exam
UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy
More informationIntroduction. Who wants to study databases?
Introduction Example databases Overview of concepts Why use database systems Who wants to study databases? What is the use of all the courses I have taken so far? This course shows very concrete how CS
More informationOctober 29, Copyright 2012 by World Class CAD, LLC. All Rights Reserved.
Create a Table with SQL October 29, 2012 Copyright 2012 by World Class CAD, LLC. All Rights Reserved. Run SQL Command Line We will begin this lesson by building a simple table. On the Start menu, select
More informationThe next section discusses when and how to design abstractions that might or might not support some features.
9.6 LINQ Support 337 3 CONSIDER naming factory types by concatenating the name of the type being created and Factory. For example, consider naming a factory type that creates Control objects ControlFactory.
More informationAdvanced SQL. Nov 21, CS445 Pacific University 1
Advanced SQL Nov 21, 2017 http://zeus.cs.pacificu.edu/chadd/cs445f17/advancedsql.tar.gz Pacific University 1 Topics Views Triggers Stored Procedures Control Flow if / case Binary Data Pacific University
More information3/3/2008. Announcements. A Table with a View (continued) Fields (Attributes) and Primary Keys. Video. Keys Primary & Foreign Primary/Foreign Key
Announcements Quiz will cover chapter 16 in Fluency Nothing in QuickStart Read Chapter 17 for Wednesday Project 3 3A due Friday before 11pm 3B due Monday, March 17 before 11pm A Table with a View (continued)
More informationElements of the E-R Model
Chapter 3: The Entity Relationship Model Agenda Basic Concepts of the E-R model (Entities, Attributes, Relationships) Basic Notations of the E-R model ER Model 1 Elements of the E-R Model E-R model was
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationASSIGNMENT 4. Web. Change Manager Collaborative Pub Project Manager. Activity Manager User Manager File Manager
ASSIGNMENT 4 Package Diagram of CU-WME Sytem UI Web Domain Change Manager Collaborative Pub Project Manager Technical Services Activity Manager User Manager File Manager Note: This diagram has been decided
More informationmicro-framework Documentation
micro-framework Documentation Release 2.0.2 phpmv Apr 03, 2018 Installation configuration 1 Ubiquity-devtools installation 1 2 Project creation 3 3 Project configuration 5 4 Devtools usage 9 5 URLs 11
More informationServer side scripting and databases
Example table Server side scripting and databases student How Web Applications interact with server side databases - part 2 student kuid lastname money char char int student table Connecting and using
More informationUsing Java reflection to reduce Code and Development time in DFS
Using Java reflection to reduce Code and Development time in DFS Java reflections is one of the most powerful API s of Java Language, this can be used to reduce code significantly. Most of the Current
More informationNEWS in MOSKITO Donnerstag, 19. Januar 12
NEWS in MOSKITO 1.2.0 SQL query monitoring Story: MoSKito should be able to inspect and analyze sql queries. It's yet unclear how exactly it can be achieved (though others do it successfully). The easiest
More informationDraft. Students Table. FName LName StudentID College Year. Justin Ennen Science Senior. Dan Bass Management Junior
Chapter 6 Introduction to SQL 6.1 What is a SQL? When would I use it? SQL stands for Structured Query Language. It is a language used mainly for talking to database servers. It s main feature divisions
More informationHPCC JDBC Driver. Boca Raton Documentation Team
Boca Raton Documentation Team HPCC JDBC Driver Boca Raton Documentation Team We welcome your comments and feedback about this document via email to Please include Documentation
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler
More informationHST 952. Computing for Biomedical Scientists Lecture 5
Harvard-MIT Division of Health Sciences and Technology HST.952: Computing for Biomedical Scientists HST 952 Computing for Biomedical Scientists Lecture 5 Outline Recursion and iteration Imperative and
More informationMVC - Repository-And-Unit-Of-Work
MVC - Repository-And-Unit-Of-Work What are the Repository and Unit of Work Design Patterns? When you set up an ASP.NET MVC project with the Entity framework, you can think of your project as consisting
More informationMobile Programming Lecture 10. ContentProviders
Mobile Programming Lecture 10 ContentProviders Lecture 9 Review In creating a bound service, why would you choose to use a Messenger over extending Binder? What are the differences between using GPS provider
More informationAdvanced Programming C# Lecture 12. dr inż. Małgorzata Janik
Advanced Programming C# Lecture 12 dr inż. Małgorzata Janik majanik@if.pw.edu.pl Winter Semester 2017/2018 Project part III Final Date: 22.01.2017 I encourage to prepare preview version on 15.01.2017 (next
More informationExtending Classes (contd.) (Chapter 15) Questions:
Extending Classes (contd.) (Chapter 15) Questions: 1 1. The following C++ program compiles without any problems. When run, it even prints out the hello called for in line (B) of main. But subsequently
More informationDATABASE DESIGN I - 1DL300
DATABASE DESIGN I - 1DL300 Spring 2013 An Introductory Course on Database Systems http://www.it.uu.se/edu/course/homepage/dbastekn/vt13/ Uppsala Database Laboratory Department of Information Technology,
More informationINTRODUCTION TO INDEXES AND SARGABILITY
INTRODUCTION TO INDEXES AND SARGABILITY Jared Karney @sqlknowitall http://www.sqlknowitall.com jared.karney@microsoft.com WHAT ARE INDEXES AND WHY DO WE CARE? Database objects we create Make queries run
More informationSolutions Manual. Data Structures and Algorithms in Java, 5th edition International Student Version. M. T. Goodrich and R.
Solutions Manual Data Structures and Algorithms in Java, 5th edition International Student Version M. T. Goodrich and R. Tamassia Chapter 1 Reinforcement Solution R-1.1 Since, after the clone, A[4] and
More information1: ssis 2 2: CSV 3 3: CSV 13. 4: CSVSQL Server 19 5: 26 6: 35. 7: YYYYMMDDIntegerDate 37
ssis #ssis 1 1: ssis 2 2 Examples 2 SSIS 2005 2 2: CSV 3 3 Examples 3 CSV 3 3: CSV 13 13 13 Examples 13 13 4: CSVSQL Server 19 19 19 Examples 19 19 5: 26 26 26 Examples 26 26 SSIS 26 26 6: 35 Examples
More informationCSIS 1624 CLASS TEST 6
CSIS 1624 CLASS TEST 6 Instructions: Use visual studio 2012/2013 Make sure your work is saved correctly Submit your work as instructed by the demmies. This is an open-book test. You may consult the printed
More informationArchitectural patterns
Architectural patterns Open Source & DOTNET platform Understanding architectural design patterns (like MVC, MVP, MVVM etc.) is essential for producing a maintainable, clean, extendable and testable source
More informationAnything You Can Do I Can Do Better
Anything You Can Do I Can Do Better Algebraic Data Types Dynamic type Pattern Matching Constructors Extension Methods Play GATDs A Simple Concrete Example public class Thermometer public static event
More informationTable of contents. CppDepend CQLinq Performance 2 / 21
CQLINQ SYNTAX Table of contents 1. Introduction... 3 2. CQLinq Query Edition... 4 3. Predefined domains... 5 4. Defining the code base view JustMyCode with notmycode prefix... 7 5. CQLinq Code Rules...
More information