I have a database of strings that contain IDs. I need to pass that list into a LINQ query so I can pull the correct records.
std::stoi
model.SelectedDealers = db.dealers.Any(a => a.sdealer_name.Contains(UserToEdit.UserViewAccesses.Select(s => s.ViewReferenceNumber)));
is of type SelectedDealers
dealers
should be a list of ViewReferenceNumber
So essentially I am trying to find all of the strings which should match sdealer_name
whos dealers
matches the list of sdealer_name
I have in my sdealer_names
I've tried moving parts around and switching them in different spots and can't seem to figure this out.
答案 0 :(得分:1)
Any() is just a boolean indicating if there are any results. It doesn't actually return the results.
If I understand what you are after correctly, then this might work:
package com.example.chris.sunil_gupta;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.CallLog;
import android.widget.ListView;
public class MainActivity extends Activity {
private List <CallData>list = new ArrayList<CallData>();
private Context context=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
final ListView listview;
final String callType;
final String phoneNumber;
final String callDate;
final String callDuration;
final Date callDateTime;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context=this;
listview=(ListView)findViewById(R.id.ListView_CallData);
getCallDetails();
CustomAdapter adapter = new CustomAdapter(MainActivity.this, list);
listview.setAdapter(adapter);
}
public void getCallDetails()
{
@SuppressWarnings("deprecation")
Cursor managedCursor = managedQuery( CallLog.Calls.CONTENT_URI,null, null,null, null);
int number = managedCursor.getColumnIndex( CallLog.Calls.NUMBER );
int type = managedCursor.getColumnIndex( CallLog.Calls.TYPE );
int date = managedCursor.getColumnIndex( CallLog.Calls.DATE);
int duration = managedCursor.getColumnIndex( CallLog.Calls.DURATION);
while (managedCursor.moveToNext())
{
phoneNumber = managedCursor.getString(number);
callType = managedCursor.getString(type);
callDate = managedCursor.getString(date);
callDateTime = new Date(Long.valueOf(callDate));
callDuration = managedCursor.getString(duration);
String cType = null;
int cTypeCode = Integer.parseInt(callType);
switch(cTypeCode)
{
case CallLog.Calls.OUTGOING_TYPE:
cType = "OUTGOING";
break;
case CallLog.Calls.INCOMING_TYPE:
cType= "INCOMING";
break;
case CallLog.Calls.MISSED_TYPE:
cType = "MISSED";
break;
}
CallData calldata=new CallData(cType, phoneNumber, callDateTime, callDuration);
list.add(calldata);
}
managedCursor.close();
}
}
答案 1 :(得分:0)
所以基本上我试图找到所有的经销商 sdealer_name匹配我的sdealer_names列表 UserToEdit.UserViewAccesses
var dealersthatmatched = (from d in UserToEdit.UserViewAccesses.sdealer_names
where d == sdealer_name
select d).ToList()
希望我可以发表评论,但由于我没有足够的代表,我不能。我希望我能更好地理解这个要求,但你似乎已经准备好并且能够尝试一些东西,所以也许你觉得这很有用。