datamapper

Data Mapper Pattern

我们两清 提交于 2019-12-02 20:35:59
Up until now I've been using Active records in all my c# database driven applications. But now my application requires my persistence code being split from my business objects. I have read a lot of posts regarding Martin Fowler's data mapping pattern, but my knowledge of this pattern is still very limited. Let's use the following example: If I have 2 tables - Customer and CustomerParameters. The CustomerParameters table contains default Customer values for creating a new Customer. I will then have to create a CustomersMapper class to handle all of the Customer persistence. My Customer and

How is the Data Mapper pattern different from the Repository Pattern?

一世执手 提交于 2019-12-02 15:13:32
I found two patterns which appear to have the same goal - what is the difference? http://martinfowler.com/eaaCatalog/dataMapper.html http://martinfowler.com/eaaCatalog/repository.html Andrei [the Repository is] another layer of abstraction over the mapping layer where query construction code is concentrated. The DataMapper ensures the DB side of the fence doesn't need to know about the specifics of your business logic and how the data is kept in memory by your business objects and your business side of the fence doesn't need to know how the data is stored. To illustrate, consider that your

How to add property-level Attribute to map ColumnAttribute at runtime?

老子叫甜甜 提交于 2019-12-02 10:11:51
From this question we have implemented the ColumnAttribute association with the corresponding property, but when Linq to SQL tries to map this property to a Column it doesn't work. Our property and mapping code(from the other question): public System.Xml.Linq.XElement Name { get { return this.name; } set { this.OnNameChanging(value); this.SendPropertyChanging(); this.name = value; this.SendPropertyChanged("Name"); this.OnNameChanged(); } } System.Data.Linq.Mapping.ColumnAttribute columnAttribute = new System.Data.Linq.Mapping.ColumnAttribute(); columnAttribute.Name = "Name"; columnAttribute

Undefined method auto_upgrade! when pushing Sinatra/DataMapper app to Heroku

不羁岁月 提交于 2019-12-01 18:16:15
Does anybody know the magic incantation required to get a Sinatra application that uses DataMapper up and running on Heroku's Bamboo stack? The Bamboo stack doesn't include any pre-installed system gems and no matter what combination of gems I try I keep getting this error: undefined method `auto_upgrade!' for DataMapper:Module (NoMethodError) This is what I have in my .gems file: sinatra pg datamapper do_postgres dm-postgres-adapter And these are the dependencies that are installed when I push the app to Heroku: -----> Heroku receiving push -----> Sinatra app detected -----> Installing gem

Undefined method auto_upgrade! when pushing Sinatra/DataMapper app to Heroku

随声附和 提交于 2019-12-01 17:30:48
问题 Does anybody know the magic incantation required to get a Sinatra application that uses DataMapper up and running on Heroku's Bamboo stack? The Bamboo stack doesn't include any pre-installed system gems and no matter what combination of gems I try I keep getting this error: undefined method `auto_upgrade!' for DataMapper:Module (NoMethodError) This is what I have in my .gems file: sinatra pg datamapper do_postgres dm-postgres-adapter And these are the dependencies that are installed when I

Handling items in the collection pattern by a data mapper

青春壹個敷衍的年華 提交于 2019-12-01 09:13:13
My question is related to the update section of @tereško's answer in " Who should handle the conditions in complex queries, the data mapper or the service layer? " Below is the code for reference and convenience. $category = new Category; $category->setTitle( 'privacy' ); $list = new ArticleCollection; $list->setCondition( $category ); $list->setDateRange( mktime( 0, 0, 0, 12, 9, 2001) ); // it would make sense, if unset second value for range of dates // would default to NOW() in mapper $mapper = new ArticleCollectionMapper; $mapper->fetch( $list ); foreach ( $list as $article ) { $article-

Handling items in the collection pattern by a data mapper

余生颓废 提交于 2019-12-01 06:27:59
问题 My question is related to the update section of @tereško's answer in "Who should handle the conditions in complex queries, the data mapper or the service layer?" Below is the code for reference and convenience. $category = new Category; $category->setTitle( 'privacy' ); $list = new ArticleCollection; $list->setCondition( $category ); $list->setDateRange( mktime( 0, 0, 0, 12, 9, 2001) ); // it would make sense, if unset second value for range of dates // would default to NOW() in mapper

Installing dm-types on Windows. (Win7 x64)

青春壹個敷衍的年華 提交于 2019-11-30 21:34:21
I am trying to install dm-types for DataMapper on my machine with gem install dm-types I've installed Ruby from RubyInstaller (1.9.3) and I also have the DevKit installed. (Aswell as some other gems like sinatra, haml, dm-core and bcrypt-ruby). However, when I run "gem install dm-types", this happens. C:\Users\Lev>gem install dm-types Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing dm-types: ERROR: Failed to build gem native extension. "C:/Program Files (x86)/Ruby/Ruby193/bin/ruby.exe" extconf.rb creating Makefile

Having difficulty accessing validation errors in Sinatra

和自甴很熟 提交于 2019-11-30 19:58:31
问题 I have a very basic form, with some very basic validations (though I need to create a custom validation later... you'll probably see a question on that tomorrow. =P ), but I'm having trouble showing the user the validation errors. Here's my main Sinatra file: $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'sinatra' require 'rubygems' require 'datamapper' require 'dm-core' require 'dm-validations' require 'lib/authorization' DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/entries.db")

Master / Slave switch in the Zend Framework application layer

∥☆過路亽.° 提交于 2019-11-30 14:30:25
I am writing an application which requires the Master/Slave switch to happen inside the application layer. As it is right now, I instantiate a Zend_Db_Table object on creation of the mapper, and then setDefaultAdapter to the slave. Now inside of the base mapper classe, I have the following method: public function useWriteAdapter() { if(Zend_Db_Table_Abstract::getDefaultAdapter() != $this->_writeDb) { Zend_Db_Table_Abstract::setDefaultAdapter($this->_writeDb); $this->_tableGateway = new Zend_Db_Table($this->_tableName); } } I need a sanity check on this. I don't think the overhead is too much,