我有一个Oracle数据库,其中一个字段是日期范围字段.它基本上只是作为VARCHAR(40)存储在数据库中,格式为YYYY/MM/DD-YYYY/MM/DD.我想将它在nHibernate中映射到我这样创建的自定义类
public class DateTimeRange
{
public DateTimeRange(DateTime fromTime, DateTime toTime)
{
FromTime = fromTime;
ToTime = toTime;
}
public override string ToString()
{
return String.Format("{0} to {1}", FromTime.ToString("HH:mm:ss"), ToTime.ToString("HH:mm:ss"));
}
public DateTime FromTime { get; set; }
public DateTime ToTime { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
如何映射到这样的自定义类?
我们正在开发一个项目,将OSM和NAVTEQ的矢量地图数据添加到iOS GPS应用程序中.
目前,该应用程序显示栅格地图图像并提供移动地图导航功能.我们现在想通过集成矢量图更进一步,但不知道从哪里开始.
具有GPS导航经验的开发人员的指导将是很好的.
以下是要求的简要说明:
目标设备: iOS.C++是核心的首选,以便将来与其他平台兼容.
数据集成和打包: 地图数据源: - NAVTEQ - OpenStreetMap
文件格式: - 考虑到设备限制的移动设备的理想选择. - 要么找到已经建立的格式,要么在内部创建一个.
编译: - 确定源数据的格式(Shp,MapInfo等) - 将源格式编译为所需格式.
地图渲染引擎:地图 显示: - 矢量地图视图将与当前栅格地图视图分开. - 实时将数据渲染为线,点,多边形等.平铺或预渲染是不可接受的. - 2D鸟瞰图.(3D计划用于未来版本). - 阴影浮雕来说明海拔. - 显示用户生成的数据,例如路线,轨道日志,航点. - 比例尺,例如500米. - 快速的性能对于提供更好的用户体验至关重要. - 很好的例子是Tom Tom iOS应用程序. 地图交互: - 平移,缩放,旋转. - 利用多点触控功能.搜索 - 地址,位置,POI(地理编码) - 地址(反向地理编码)
样式表 - 轻松自定义已显示的地图外观. - 每个元素都可以通过cusomised.
我们想知道从哪里开始我们的研究.那些值得花时间调查的库和SDK是什么?
我相信这一定是相当简单的,但这是一个难以言喻的问题.我甚至不知道谷歌的用途.
我不是在寻找任何复杂的解决方案.基本上,我在画布上绘制线条,我想要不同的颜色,具体取决于线条的长度.通常我只是缩放红色通道(#ff0000*(线长)/(最大线长)),但这个解决方案并不理想.我只是想找一个方程式,它会给出彩虹渐变上某个位置的#rrggbb值,如果这有意义的话.
感谢能为您提供帮助的人!非常感谢.
我希望能够分别用tab和shift-tab突出显示我想缩进/反向缩进和缩进的行.
" for command mode reverse tab
nmap <S-Tab> <<
" for insert mode reverse tab
imap <S-Tab> <Esc><<i
" for command mode multiple line reverse tab(doesn't work)
nmap <Tab> i<
" for insert mode multiple line reverse tab(doesn't work)
imap <Tab> <
" for command mode tab
nmap <Tab> >>
" for command mode multiple line tab(doesn't work)
nmap <Tab> i>
" for insert mode multiple line tab(doesn't work)
imap <Tab> >
Run Code Online (Sandbox Code Playgroud)
在我愿意使用vim作为我的主编辑之前,这是我需要的最后一件事.
我对AutoMapper有些新意,并希望将POCO-ish对象映射到可能更复杂的DTO,后者试图表示Google Books API的Volume资源:
Book.cs
public class Book
{
public string Isbn10 { get; set; }
public string Isbn13 { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public string Publisher { get; set; }
public DateTime Publication { get; set; }
public int Pages { get; set; }
public string Description { get; set; }
public bool InStock { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
BookDto.cs
public class BookDto
{
public …Run Code Online (Sandbox Code Playgroud) 我正在使用Entity Framework 5(使用Code First方法)从带有参数的遗留存储过程填充我的一类,这很正常(详情如下).我的问题是我想将列的名称映射到具有不同名称的属性(我不喜欢来自Erp的名称).我尝试使用Configuration类(就像我映射到视图或表时所做的那样)来为具有不同名称的属性指定列名,这是我的结果:
为什么配置会影响我的结果,但其规范不用于映射列?有没有其他方法使用SqlQuery指定此映射?
以下是详细信息:
我的POCO课程:
public class Item
{
public String Id { get; set; }
public String Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
配置类:
public class ItemConfiguration : EntityTypeConfiguration<Item>
{
public ItemConfiguration()
{
HasKey(x => new { x.Id });
Property(x => x.Id).HasColumnName("Code");
Property(x => x.Description).HasColumnName("ItemDescription");
}
}
Run Code Online (Sandbox Code Playgroud)
存储过程返回带有"Code"和"ItemDescription"列的数据; 我用这种方式称呼它:
var par = new SqlParameter();
par.ParameterName = "@my_par";
par.Direction = ParameterDirection.Input;
par.SqlDbType = SqlDbType.VarChar;
par.Size = 20;
par.Value = ...;
var data = _context.Database.SqlQuery<Item>("exec …Run Code Online (Sandbox Code Playgroud) mapping configuration stored-procedures ef-code-first entity-framework-5
我试图Discriminator在一个从另一个扩展的实体中使用a .这是我制作的代码:
/**
* @ORM\Entity
* @ORM\Table(name="usuarios_externos.usuarios", schema="usuarios_externos")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({
* "natural" = "Natural",
* "empresa" = "Empresa"
* })
* @UniqueEntity(fields={"correo_alternativo"}, message="El correo electrónico ya está siendo usado.")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class Usuario extends BaseUser {
....
}
Run Code Online (Sandbox Code Playgroud)
但是在运行命令时我收到此错误doctrine:schema:validate:
[Doctrine\ORM\Mapping\MappingException]实体'UsuarioBundle\Entity\Usuario'必须是'UsuarioBundle\Entity\Usuario'的鉴别器映射的一部分才能在继承层次结构中正确映射.或者,您可以将"UsuarioBundle\Entity\Usuario"设为抽象类,以避免发生此异常.
有任何解决这个问题的方法吗?可以在扩展类中使用Discriminator吗?
我只搜索几个字段,但我希望能够将整个文档存储在ES中,以免其他DB(MySQL)查询.
我试图加入index: no,store: no在整个映射对象/属性,但我仍然不知道,如果字段被索引并添加不必要的开销.
假设我有书,每个人都有作者.我想只按书名搜索,但我希望能够检索整个文档.
这个可以吗:
mappings:
properties:
title:
type: string
index: analyzed
author:
type: object
index: no
store: no
properties:
first_name:
type: string
last_name:
type: string
Run Code Online (Sandbox Code Playgroud)
或者我应该这样做:
mappings:
properties:
title:
type: string
index: analyzed
author:
type: object
properties:
first_name:
index: no
store: no
type: string
last_name:
index: no
store: no
type: string
Run Code Online (Sandbox Code Playgroud)
或者我可能完全错了?关于什么的nested性质不应被编入索引?
这是一个漫长的过程.
所以,我有一个模型和一个viewmodel,我正在从AJAX请求更新.Web API控制器接收viewmodel,然后我使用AutoMapper更新现有模型,如下所示:
private User updateUser(UserViewModel entityVm)
{
User existingEntity = db.Users.Find(entityVm.Id);
db.Entry(existingEntity).Collection(x => x.UserPreferences).Load();
Mapper.Map<UserViewModel, User>(entityVm, existingEntity);
db.Entry(existingEntity).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch
{
throw new DbUpdateException();
}
return existingEntity;
}
Run Code Online (Sandbox Code Playgroud)
我为User - > UserViewModel(和back)映射配置了自动配置.
Mapper.CreateMap<User, UserViewModel>().ReverseMap();
Run Code Online (Sandbox Code Playgroud)
(注意,显式设置相反的地图并省略ReverseMap表现出相同的行为)
我遇到的Model/ViewModel成员是一个不同对象的ICollection问题:
[DataContract]
public class UserViewModel
{
...
[DataMember]
public virtual ICollection<UserPreferenceViewModel> UserPreferences { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
相应的模型是这样的:
public class User
{
...
public virtual ICollection<UserPreference> UserPreferences { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
问题:
除了ICollections上面显示的UserPreferences/UserPreferenceViewModels 之外,User和UserViewModel类的每个属性都正确映射.当这些集合从ViewModel映射到Model而不是map属性时,将从ViewModel创建UserPreference对象的新实例,而不是使用ViewModel属性更新现有对象.
模型:
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Haskell中实现树处理算法,并且(由于这是我的第一个Haskell程序!)正在为数据结构的设计而苦苦挣扎。那里的任何FP专家都可以伸出援手吗?
首先,我将描述算法的重要特征,勾勒出如何使用命令式语言来实现这一点,最后完成到目前为止在Haskell中遇到的绊脚石。
我不会详细描述完整的算法,但是要点如下:
因此,数据结构必须具有以下特征:
如果我要使用命令式语言实现此算法,则解决方案将类似于以下内容。
假设起点是输入树的以下定义:
struct node {
// Identifier for this node, unique within the containing tree
size_t id;
// Label of this node
enum label label;
// Attributes of this node
// An attribute can be assumed to be a key-value pair
// Details of the attributes themselves aren't material to this
// discussion, so the "attribute" type is left opaque
struct attribute **attributes;
size_t n_attributes;
// …Run Code Online (Sandbox Code Playgroud) mapping ×10
automapper ×2
.net ×1
algorithm ×1
c# ×1
colors ×1
doctrine-orm ×1
dto ×1
gis ×1
haskell ×1
indentation ×1
ios ×1
javascript ×1
nhibernate ×1
orm ×1
php ×1
symfony ×1
tabs ×1
tree ×1
vim ×1