在境界中,
是否可以根据另一个属性的值设置持久属性的默认值?
例如。我有一个List<DeviceDetails> devicedetails = (
from devices in db.Device
join devicespecifications in db.DeviceSpecifications on devices.DeviceID equals devicespecifications.DeviceFKID
join devicetypes in db.Types on devices.DeviceTypeFKID equals devicetypes.DeviceTypeID
join specvalue in db.Types on devicespecifications.DeviceTypeFKID equals devicetypes.DeviceTypeID // This Line is giving me the above mentioned error
join devicehistories in db.DeviceHistory on devices.DeviceID equals devicehistories.DeviceFKID
join locations in db.Locations on devices.LocationFKID equals locations.LocationID
join ips in db.IP on devices.DeviceID equals ips.DeviceFKID
where devices.DeviceID == id
select new DeviceDetails()
{
DeviceID = devices.DeviceID,
DeviceName = devices.DeviceName,
EntryDate = devices.EntryDate,
AssignDate = devices.AssignDate,
DeviceStatus = devices.DeviceStatus.ToString(),
MACAddress = devices.MACAddress,
DateRepaired= devicehistories.DateRepaired,
Remarks= devicehistories.Remarks,
SpecificationType = devicespecifications.DeviceTypeFKID,
devicetypes.DeviceTypeID,
SpecificationValue = devicespecifications.SpecificationValue,
FamilyIP = ips.FamilyIP,
ChildIP = ips.ChildIP,
LocationTypeValue = locations.LocationTypeValue,
DeviceTypeValue = devicetypes.DeviceTypeValue
}).ToList<DeviceDetails>();
return devicedetails;
}
属性,包括UpperCase / LowerCase / Accents / etc.我希望有name
将tokenizedName
属性转换为更简单的字符串(全部为大写,无重音符号)。
答案 0 :(得分:2)
您可以使用派生属性轻松完成此操作:
tokenizedName
此处name
和name
是Realm中保留的属性,而忽略name
。每次从@interface Person : RLMObject
@property (nonatomic, copy) NSString *name;
@property NSString *_name;
@property NSString *tokenizedName;
@end
@implementation Person
- (NSString *)name {
return self._name;
}
- (void)setName:(NSString *)name {
self._name = name;
// perform tokenization...
self.tokenizedName = name.lowercaseString;
}
+ (NSArray<NSString *> *)ignoredProperties {
return @[@"name"];
}
@end
读取内容时,您都只是来自其底层存储空间。每次写入params = ActionController::Parameters.new({ review_queue_id: @review_queue_application.id })
时,都会设置其后备存储并更新标记化版本。
编辑:在Objective-C
controller.params = ActionController::Parameters.new({ review_queue_id: @review_queue_application.id })