如何使用 ServiceStack.OrmLite 创建多列的唯一约束? [英] How to Create Unique Constraint with Multiple Columns using ServiceStack.OrmLite?

查看:57
本文介绍了如何使用 ServiceStack.OrmLite 创建多列的唯一约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 ServiceStack.OrmLite 创建唯一约束(希望使用属性)?该文档显示了如何仅在单个列上创建唯一约束:

How does one create a unique constraint with ServiceStack.OrmLite (using attributes, hopefully)? The documentation shows how to create a unique constraint only on a single column:

ServiceStack.OrmLite 文档

如果有帮助,我正在使用 ServiceStack.OrmLite.SqlServer.

If it helps, I am using ServiceStack.OrmLite.SqlServer.

推荐答案

Service Stack 似乎有一个 CompositeIndex 属性,它采用多个字段名称.下面来看看构造函数...

Service Stack appears to have a CompositeIndex attribute which takes multiple field names. Here's a look at the constructors...

CompositeIndexAttribute(params string[] fieldNames);
CompositeIndexAttribute(bool unique, params string[] fieldNames);

这篇关于如何使用 ServiceStack.OrmLite 创建多列的唯一约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆