Originally created by @asadali737 on GitHub (Dec 27, 2018).
I was using CoreStore for a very long time. Today I just updated in to the newest version. It things get little bit complicated for me. I am unable to resolve the error.
This is my class, according to new CoreStore version.
class Temp: CoreStoreObject {
let abc = Value.Required<String>("abc", initial: "")
let xyz = Value.Required<Int>("xyz", initial: 0)
}
Now somewhere in code I need to get sum of xyz from database. I read the docs and following is the code for it.
let sum = transaction.queryValue(From<Temp>().select(.sum(\Temp.xyz)))
But I am getting following error on this line. Please help me to solve it.
Reference to member 'sum' cannot be resolved without a contextual type
Cocoa Pod version: 1.5.3
CoreStore version: 5.3.1
Previously I was using following code to get the sum if let sum = transaction.queryValue(From<Temp>(), Select<Int>(.sum("xyz")), Where("abc = ' '")) { }
Originally created by @asadali737 on GitHub (Dec 27, 2018).
I was using CoreStore for a very long time. Today I just updated in to the newest version. It things get little bit complicated for me. I am unable to resolve the error.
This is my class, according to new CoreStore version.
```
class Temp: CoreStoreObject {
let abc = Value.Required<String>("abc", initial: "")
let xyz = Value.Required<Int>("xyz", initial: 0)
}
```
Now somewhere in code I need to get sum of `xyz` from database. I read the docs and following is the code for it.
`let sum = transaction.queryValue(From<Temp>().select(.sum(\Temp.xyz)))`
But I am getting following error on this line. Please help me to solve it.
`Reference to member 'sum' cannot be resolved without a contextual type`
Cocoa Pod version: 1.5.3
CoreStore version: 5.3.1
Previously I was using following code to get the sum
`if let sum = transaction.queryValue(From<Temp>(), Select<Int>(.sum("xyz")), Where("abc = ' '")) { }`
Sorry I missed responding to this. Looks like I missed adding a generic-resolved method for this. For now you can try writing
ifletsum=transaction.queryValue(From<Temp>().select(Int.self,.sum(\.xyz))// Note the first argument.where(\.abc==" "))
@JohnEstropia commented on GitHub (Jan 16, 2019):
Sorry I missed responding to this. Looks like I missed adding a generic-resolved method for this. For now you can try writing
```swift
if let sum = transaction.queryValue(
From<Temp>()
.select(Int.self, .sum(\.xyz)) // Note the first argument
.where(\.abc == " ")
)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @asadali737 on GitHub (Dec 27, 2018).
I was using CoreStore for a very long time. Today I just updated in to the newest version. It things get little bit complicated for me. I am unable to resolve the error.
This is my class, according to new CoreStore version.
Now somewhere in code I need to get sum of
xyzfrom database. I read the docs and following is the code for it.let sum = transaction.queryValue(From<Temp>().select(.sum(\Temp.xyz)))But I am getting following error on this line. Please help me to solve it.
Reference to member 'sum' cannot be resolved without a contextual typeCocoa Pod version: 1.5.3
CoreStore version: 5.3.1
Previously I was using following code to get the sum
if let sum = transaction.queryValue(From<Temp>(), Select<Int>(.sum("xyz")), Where("abc = ' '")) { }@JohnEstropia commented on GitHub (Jan 16, 2019):
Sorry I missed responding to this. Looks like I missed adding a generic-resolved method for this. For now you can try writing