This is the code I have for loading my data entities.
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<msPlaylistItem>(m => m.tbMedia);
dlo.LoadWith<tbMedia>(a => a.tbArtists);
dlo.LoadWith<msNote>(n => n.tbMedia.msNotes);
db.LoadOptions = dlo;
dlo.LoadWith(n => n.tbMedia.msNotes); This is the line I am having a problem with. This is the error "The expression specified must be of the form p.A, where p is the parameter and A is a property or field member."
What I am trying to do is load the notes that are related to the each tbMedia object.
this is the correct line
dlo.AssociateWith <tbMedia>(t => t.msNotes.Where(n => n.MediaId == n.tbMedia.id));
Related
When I query my listview with automation Id in the Repl() window I get back a chunk of data. I only want back one field 'Text' or 'Label'
here is my query:
app.Query(q => q.Id("officerList").Descendant().Id("officerName").Index(0).Class("UILabel").Index(0))
here is the return: [ [0] {
Id => null,
Description => ">",
Rect => {
Width => 88,
Height => 20.5,
X => 12,
Y => 144,
CenterX => 56,
CenterY => 154.25
},
Label => "Abril, Jill M.",
Text => "Abril, Jill M.",
Class => "UILabel",
Enabled => true
}
]
I want to continue the query and return only "Abril, Jill M."
I tried adding .Label no luck it broke with error:
(1,103): error CS1061: Type Xamarin.UITest.Queries.AppQuery' does not contain a definition forLabel' and no extension method Label' of typeXamarin.UITest.Queries.AppQuery' could be found. Are you missing an assembly reference
This should work:
var query = app.Query(q => q.Id("officerList")
.Descendant().Id("officerName")
.Index(0).Class("UILabel")
.Index(0));
var labelText = query[0]?.Text;
labelText should contain the value of the label you want.
In resume, the Query returns an Array of AppResult (AppResult[]). You need to get the item you want which is this case is the first item.
Hope this helps.-
You can try this query also for Label -
q.Id("officerList").Descendant().Id("officerName").Index(0).Class("UILabel").Index(0)).Label
Output - "Abril, Jill M.", ,
OR For Text
q.Id("officerList").Descendant().Id("officerName").Index(0).Class("UILabel").Index(0)).first.text
Output - "Abril, Jill M."
May be this would work
Good Day:
I'm using ElasticSearch/NEST to query against nested objects. What I realize is that my nested object is empty however, the parent is being returned despite there being now match.
ISearchResponse<Facility> responses = await this._elasticClient.SearchAsync<Facility>(a => a.Query(q =>
q.Bool(b =>
b.Must(m =>
m.Nested(n =>
n.Query(nq =>
nq.Term(t =>t.Field(f => f.Reviews.First().UserId).Value(user.Id))
).InnerHits(ih => ih.From(0).Size(1).Name("UserWithReview"))
)
)
)
));
When I look at the generated query, I"m even more confused what is happening:
Successful low level call on POST: /dev/doc/_search?typed_keys=true
# Audit trail of this API call:
- [1] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.9806442
# Request:
{}
As you can see the request is empty.
You haven't defined the nested query with all the properties needed; it's missing the Path property, which tells Elasticsearch which document field (i.e. path) to execute the query on. Looking at the rest of the query, it looks like this should be the Reviews property
ISearchResponse<Facility> responses =
await this._elasticClient.SearchAsync<Facility>(a => a
.Query(q => q
.Bool(b => b
.Must(m => m
.Nested(n => n
.Path(f => f.Reviews) // <-- missing
.Query(nq => nq
.Term(t => t
.Field(f => f.Reviews.First().UserId)
.Value(user.Id)
)
)
.InnerHits(ih => ih.From(0).Size(1).Name("UserWithReview"))
)
)
)
)
);
I Had a master table: Processes.
Processes has a detail subtable named: Movements.
One discriminator of Movement is named: Distribution.
And it has a field named Number.
I need to filter processes that have Movements->Distribution->Number like '%123%'.
I tried with:
IEnumerable<Process> filtereds = db.Processes
.Include(s => s.Movements)
.Where(sm => sm.Number.Contains("%123%"))
I was warned that Number does not exist. I think it is because Number is a field of Distribution, a child of Movement.
Then I tried:
IEnumerable<Process> filtereds = db.Processes
.Include(s => s.Movements)
.OfType(Distribution)
.Where(sm => sm.Number.Contains("%123%"))
I was warned that Distribution does not valid in this context.
Then I found:
IEnumerable<Process> filtereds = db.Processes
.Include(s => s.Movements)
.OfType<Distribution>()
.Any(c => c.Number.Contains("123")));
But when I run with two filter parameters:
IEnumerable<Process> filtereds = db.Processes
.Include(c => c.Customers
.Include(s => s.Movements)
filtereds = filtereds
.Where(sc => sc.Movements.OfType<Distribution>().Any(c => c.Number.Contains(model.Nbr)));
filtereds = filtereds
.Where(sc => sc.Customer.Any(cl => cl.Customer.Name.Contains(model.Customer)));
The first one runs correctly.
but the second return:
"There is already an open DataReader associated with this Command that must be closed first."
You should be able to include Distribution if it is in a secondary table with:
db.Processes
.Include(p => p.Movements.Distribution)
.Where(p => p.Movements.Any(pm => pm.Distribution.Any(pmd => pmd.Number.Contains("123")))
I am not sure if you will need to Include(p => p.Movements) first.
I want to get the call details, from a second leg call, and insert them into my database.
Here is the scenario: an inbound call to a toll-free number is routed to second phone. So there are 2 legs, 1) the inbound call to the toll-free number and then 2) connection to the second number.
The code for getting the call details for the FIRST leg is:
get '/hangup' do
user_key = numbers.where(:number => params["To"]).join(:credentials, :user_id => :user_id).get(:user_key)
user_token = numbers.where(:number => params["To"]).join(:credentials, :user_id => :user_id).get(:user_token)
call_sid = params["CallSid"]
call_parent_sid = ["ParentCallSid"]
#sub_account_client = Twilio::REST::Client.new(user_key, user_token)
#subaccount = #sub_account_client.account
call = #subaccount.calls.get(call_sid)
call_sid = call.sid,
call_parent_sid = call.parent_call_sid,
phone_number_id = call.phone_number_sid,
call_from = call.from,
call_to = call.to,
call_start = call.start_time,
call_end = call.end_time,
call_duration = call.duration,
charged_duration = ((call_duration.to_f)/60).ceil
call_price = call.price
call_charged_price = (charged_duration * 0.07)
call_logs.insert(:call_sid => call_sid, :call_parent_sid => call_parent_sid, :phone_number_id => phone_number_id, :call_from => call_from, :call_to => call_to, :call_start => call_start, :call_end => call_end, :call_duration => call_duration, :charged_duration => charged_duration, :call_price => call_price, :call_charged_price => call_charged_price)
end
This works after hangup and the status_callback_url is '/hangup'. But how can I get the same details for the second leg of the call. I have tried as follows:
get '/receive' do
destination_number = numbers.where(:number => params["To"]).join(:users, :id => :user_id).get(:primary_number)
user_id = numbers.where(:number => params["To"]).join(:users, :id => :user_id).get(:id)
greeting_url = voicemail.where(:user_id => user_id).get(:voicemail_play_url)
resp = Twilio::TwiML::Response.new do |r|
r.Dial destination_number, :status_callback => '/hangup_second_leg', :status_callback_method => 'GET'
etc..
This effectively attempts to create a second status_callback_url which, needless to say, did not work.
So, how can I get the details of the second (or even third) leg of a call and bung it into my DB?
Twilio evangelist .....
Many thanks in advance.
Twilio developer evangelist at your service!
I just ran a quick test and the parameters you get back from the hangup callback should include a "CallSid" and a "DialedCallSid" which are the two legs of your call. You can get hold of the data via normal calls to the REST api:
get '/hangup' do
call_sid = params["CallSid"]
dialed_call_sid = params["DialedCallSid"]
#sub_account_client = Twilio::REST::Client.new(user_key, user_token)
#subaccount = #sub_account_client.account
inbound = #subaccount.calls.get(call_sid)
outbound = #subaccount.calls.get(dialed_call_sid)
# Update calls in database
end
Alternatively, the inbound call is the parent of all the other calls that take part within the context of the call. So you can get the details on all the child calls with the following api calls:
#subaccount.calls.list parent_call_sid: params["CallSid"]
# => [<Twilio::REST::Call>, ...]
Also, if you are getting a ParentCallSid parameter in your hangup, then you can use the above code to look up the parent call and child calls from that too.
Hope this helps, let me know if there's anything else I can help with.
$updatedOrder = array(
'ship_status' => 'shipped',
'shipped_carrier' => (string)$selectedShipper->shipper->name,
'base_rate' => (float)$selectedShipper->rate,
'discount_rate' => (float)$selectedShipper->rate,
'tracking_number' => '123',
);
$this->orders_m->where('id', $tmpOrder->id)
->update('orders', $updatedOrder);
This yields the following SQL query: UPDATE default_orders SET ship_status = 'shipped', shipped_carrier = 'UPS Next Day Air', base_rate = 22.85, discount_rate = 22.85, tracking_number = '123' WHERE id = '1' AND id = 'orders'
Where did that last bit come from? id='orders'?
Just make sure that $tmpOrder->id is a variable and not an array.
var_dump($tmpOrder->id);
Maybe there is an error somewhere where you are getting the $tmpOrder and it returns an array for that.