如何在Delphi(Delphi 200X,Delphi XE)中实现并行循环?怎么做这个最好的方法?有没有通用的解决方案?
请举例说明.
我需要帮助配置我的推土机映射文件.
主要是我想知道如何让用户用户obejct转换为Long userId.
因此map:user >> userId
但是我有多个对象,例如注释>> commentId或address >> addressId
因此,我想要比为每个领域编写映射更优雅.所有对象都实现了Loadable接口.
由于getParameter()DozerConverter方法,波纹管代码现在正在运行,但是如果你知道比我写的转换器更好的方法,请告诉我.
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd">
<configuration>
<custom-converters>
<converter type="project.shared.domain.dto.dozer.LoadableIdConverter" >
<class-a>project.shared.domain.Loadable</class-a>
<class-b>java.lang.Long</class-b>
</converter>
</custom-converters>
</configuration>
<mapping>
<class-a>project.shared.domain.Suggestion</class-a>
<class-b>project.shared.domain.dto.DTOSuggestion</class-b>
<field custom-converter-param="User">
<a>user</a>
<b>userId</b>
</field>
</mapping>
</mappings>\
Run Code Online (Sandbox Code Playgroud)
<bean id="loadableIdConverter" class="project.shared.domain.dto.dozer.LoadableIdConverter">
<property name="userService" ref="userService"/>
<property name="commentService" ref="commentService"/>
<property name="addressService" ref="addressService"/>
</bean>
<bean id="gwtMapper" class="org.dozer.DozerBeanMapper">
<property name="mappingFiles">
<list>
<value>classpath:/dozer.xml</value>
</list>
</property>
<property name="customConverters">
<list>
<ref bean="loadableIdConverter"/>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
public class Suggestion implements …Run Code Online (Sandbox Code Playgroud) 我想startswith在Django中做一个不区分大小写的查询:
books = Book.objects.filter(title__iexact__startswith=query)
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误消息:
FieldError at /names/
Join on field 'title' not permitted
Run Code Online (Sandbox Code Playgroud)
如何startswith在Django中指定不区分大小写?
通常我必须编写一个循环,它必须特殊情况下集合中的第一个项目,代码似乎永远不应该是清晰的.
如果没有重新设计C#语言,那么编写这些循环的最佳方法是什么?
// this is more code to read then I would like for such a common concept
// and it is to easy to forget to update "firstItem"
foreach (x in yyy)
{
if (firstItem)
{
firstItem = false;
// other code when first item
}
// normal processing code
}
// this code is even harder to understand
if (yyy.Length > 0)
{
//Process first item;
for (int i = 1; i < yyy.Length; i++)
{
// process …Run Code Online (Sandbox Code Playgroud) 如何在全局或仅在某些模式下禁用Emacs中的自动缩进?
我为RubyOnRails安装了许多软件包(ruby,html,js,css).
假设我想禁用css-mode的autoindent.
我有一个大型的视觉工作室解决方案,有大约50个项目.有StaticDebug,StaticRelease,Debug和Release的配置.dll和static lib形式都需要一些库.为了获得它们,我们使用不同的配置重建解决方案.Configuration Manager窗口用于设置需要构建哪些项目的风格,静态库,动态DLL或两者.
这可能非常难以管理,并且必须多次构建解决方案并按正确顺序选择配置有点烦人.静态版本需要在非静态版本之前构建.
我想知道,如果对于我需要生成静态lib和dynamc dll的项目,我创建了两个项目,而不是当前的方案,可能更容易管理.例如:
我可以让这两个项目引用所有相同的文件并构建它们两次,或者我想知道,是否可以构建CoreLib然后让CoreDll链接它以生成DLL?
我想我的问题是,您对如何在这种情况下构建项目有任何建议吗?
谢谢.
我想创建一个控件浮动(可能)在它的包含形式的范围之外.这可能吗?我该怎么办?
这将像上下文菜单一样功能,我只需要能够添加其他控件,如按钮和图像.
我们有以下JPA类:
@Entity
class Supplier {
// ... id property etc.
@OneToMany
@OrderBy("someProperty")
private List<Region> regions;
}
Run Code Online (Sandbox Code Playgroud)
这在正常情况下工作正常.但是,我们有其中的值存储在类似性质的一些多语种数据nameEn,nameDe,nameZh.要使用的确切属性取决于登录用户.例如,德语用户应该看到区域好像已经注释了@OrderBy("nameDe").
我怎样才能做到这一点?
我知道我可以在加载后在我的代码中对集合进行排序,但是这使得结果的分页非常困难.
我试图用一个方法定义一个类,一个缺少这些方法的类,然后允许后一个类的对象从前一个类的实例中"学习"这些方法.
这是我的尝试(Ruby 1.9.2) - 当我尝试在lambda绑定中更改'self'的值时,它会中断(在行评论"BREAKS!").
如果你能弄清楚如何解决这个问题 - 我会很高兴找到答案.
class Skill
attr_accessor :name
attr_accessor :technique
def initialize(name, &technique_proc)
@name = name
@technique = lambda(&proc)
end
end
class Person
attr_accessor :name
def initialize(name)
@name = name
end
def method_missing(m, *args)
"#{@name} the #{self.class}: I don't know how to #{m}"
end
def learn_skill(skill)
puts "#{@name} the #{self.class} is learning skill: #{skill.name}"
actual_self = self
eval "self = #{actual_self}", skill.technique.binding ####### BREAKS!
define_singleton_method skill.name.to_sym, skill.technique
end
def teach_skill(skill_name)
skill = nil
if self.respond_to?(skill_name)
puts …Run Code Online (Sandbox Code Playgroud) 我正在努力实现:
select StoreId, StoreName from Store where StoreId in (
select StoreId from Employee where EmployeeName = 'Steve Jobs')
Run Code Online (Sandbox Code Playgroud)
我有这个代码:
public class Store
{
public virtual int StoreId { get; private set; }
public virtual string StoreName { get; set; }
public virtual IList<Employee> Staff { get; set; }
}
public class Employee
{
public virtual Store Store { get; set; }
public virtual int EmployeeId { get; private set; }
public virtual string EmployeeName { get; set; }
} …Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
auto-indent ×1
c++ ×1
collections ×1
converter ×1
delphi ×1
delphi-xe ×1
django ×1
dll ×1
dozer ×1
emacs ×1
eval ×1
gwt-rpc ×1
indentation ×1
java ×1
jpa ×1
lambda ×1
mapping ×1
nhibernate ×1
proc-object ×1
python ×1
ruby ×1
spring ×1
winforms ×1