本文整理汇总了C#中System.Collections.ObservableCollection.Where方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.Where方法的具体用法?C# ObservableCollection.Where怎么用?C# ObservableCollection.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.Where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadData
public async void LoadData()
{
var golfs = await _adminDataUnit.GolfsRepository.GetAllAsync();
AvailableGolfResources = new ObservableCollection<GolfModel>(golfs.Select(x => new GolfModel(x)).OrderBy(x => x.Name));
GolfFollowResources = new ObservableCollection<GolfModel>(Golf.Golf.GolfFollowResources.Select(x => AvailableGolfResources.Where(p => p.Golf.ID == x.FollowResourceID).FirstOrDefault()));
RaisePropertyChanged("AddSelectedItems");
}
示例2: send
public void send()
{
Console.WriteLine("sending the messsages");
App.Current.Dispatcher.Invoke((Action)delegate()
{
InputBlock.Text = InputBlock.Text + Environment.NewLine + "sending the messsages" + " " + DateTime.Now.ToString();
});
_networkList = new ObservableCollection<Network>(App.am.Networks);
foreach (Network n in _networkList)
{
if (n.Status == "connected")
{
Console.WriteLine(" we are sending the messsages to " + n.Names + " Network:");
App.Current.Dispatcher.Invoke((Action)delegate()
{
InputBlock.Text = InputBlock.Text + Environment.NewLine + " we are sending the messsages to " + n.Names + " Network:" + " " + DateTime.Now.ToString();
Scroller.ScrollToBottom();
InputBlock.ScrollToEnd();
});
_prefixList = new ObservableCollection<Prefix>(App.am.Prefixs);
foreach (Prefix p in _prefixList)
{
if (p.Provider == n.Names)
{
_messageList = new ObservableCollection<Message>(App.am.Messages);
if (_messageList.Where(y => y.Sent == "F").Count() > 0)
{
Console.WriteLine("sending for :" + n.Names);
foreach (Message u in _messageList)
{
if (u.Sent == "F" && u.Numbers.Contains(p.Pre))
{
// myQs.Enqueue(n.Comm,u.Numbers,u.Messages);
App.Current.Dispatcher.Invoke((Action)delegate()
{
InputBlock2.Text = InputBlock2.Text + Environment.NewLine + "Number: " + u.Numbers + " : " + u.Messages + " " + DateTime.Now.ToString();
Scroller.ScrollToBottom();
InputBlock2.ScrollToEnd();
});
try
{
//Sender(DBObject parent, string id, string message, string number, string network)
// if (Messenger.SendUpdate(App.am, u.Id, u.Messages, u.Numbers, n.Names,n.Comm))
//{
if (Messenger.Sender(App.am, u.Id, u.Messages, u.Numbers, n.Names))
{
App.Current.Dispatcher.Invoke((Action)delegate()
{
InputBlock2.Text = InputBlock2.Text + Environment.NewLine + "Message sent:... " + u.Numbers + " " + DateTime.Now.ToString();
Scroller.ScrollToBottom();
InputBlock2.ScrollToEnd();
});
}
else
{
App.Current.Dispatcher.Invoke((Action)delegate()
{
InputBlock2.Text = InputBlock2.Text + Environment.NewLine + " Message not sent:... " + u.Numbers + " " + DateTime.Now.ToString();
Scroller.ScrollToBottom();
InputBlock2.ScrollToEnd();
});
}
Console.WriteLine("Sending process:-number:" + u.Numbers + " : " + u.Messages);
}
catch
{
App.Current.Dispatcher.Invoke((Action)delegate()
{
InputBlock.Text = InputBlock2.Text + Environment.NewLine + "there is an error somewhere....." + DateTime.Now.ToString();
Scroller.ScrollToBottom();
InputBlock2.ScrollToEnd();
});
}
}
}
}
}
}
}
}
}
示例3: GetCategoryDetails
/// <summary>
/// Get category details from database
/// </summary>
/// <param name="categoryName">Category name to filter records</param>
private void GetCategoryDetails(string categoryName)
{
LstCategoryName = new ObservableCollection<ProductCategoryDTO>(from item in ServiceFactory.ServiceClient.GetCategories()
select item).ToList();
if (!string.IsNullOrEmpty(categoryName))
{
LstCategoryName = LstCategoryName.Where(item => item.Name.Contains(categoryName)).ToList();
}
}
示例4: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
// Open file system to select file(s)
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.Multiselect = true;
Nullable<bool> result = dlg.ShowDialog(); // Display OpenFileDialog by calling ShowDialog method
byte[] rawData;
List<Tuple<string, byte[]>> dataList = new List<Tuple<string, byte[]>>();
string ext = "";
string filename = "";
// Add all files selected into the the db. If multiple files added, project destination is the same.
foreach (String file in dlg.FileNames)
{
// Get the selected file name and display in a TextBox
if (result.HasValue == true && result.Value == true)
{
rawData = File.ReadAllBytes(file);
dataList.Add(Tuple.Create(file, rawData));
ext = Path.GetExtension(file);
filename = file;
}
}
AnalysisMsgPrompt a = new AnalysisMsgPrompt(new DataGridLoader(), null);
if (a.ShowDialog() == true)
{
dgl.loadSpeakers(a.PID);
rowS = dgl.getCollection("S");
foreach (var elem in rowS.ToList())
{
((dynamic)rowS).Add((Speaker)elem);
}
foreach (var dataItem in dataList)
{
var comm = new MySqlCommand();
filename = Path.GetFileName(dataItem.Item1);
using (DBConnection db = new DBConnection())
{
comm.CommandText = "INSERT INTO Analysis (AID, Description, FileData, FileType) VALUES(@AID, @Desc, @FileAsBlob, @FileType)";
comm.Parameters.AddWithValue("@AID", filename);
if (a.Desc.Equals(""))
{
comm.Parameters.AddWithValue("@Desc", "No description");
}
else
{
//Add to analysis table
comm.CommandText = "create table if not exists analysis (AID varchar(150) primary key, File mediumblob, Description varchar(500))";
comm.ExecuteNonQuery();
comm.CommandText = "INSERT INTO analysis (AID, File, Description) VALUES(@AID, @FileAsBlob, @Desc)";
comm.Parameters.AddWithValue("@AID", dataItem.Item1);
comm.Parameters.AddWithValue("@FileAsBlob", dataItem.Item2);
if (a.Desc.Equals(""))
{
comm.Parameters.AddWithValue("@Desc", "No description");
}
else
{
comm.Parameters.AddWithValue("@Desc", a.Desc);
}
comm.ExecuteNonQuery();
//Add to the mapping table(to link with speaker)
List<Row> startsWithAge = rowS.Where(s => ((Speaker)s).SpeakerName.StartsWith(a.Age)).ToList();
MessageBox.Show(a.Age);
foreach (var row in rowS)
{
//comm.CommandText = "create table if not exists files2analysis (AID varchar(150) primary key, ID varchar(150) primary key)";
//comm.ExecuteNonQuery();
if (((Speaker)row).SpeakerName.StartsWith(a.Age))
{
db.insertIntoDB(comm);
}
comm.CommandText = "INSERT IGNORE INTO files2analysis (ID, AID) VALUES (@ID2, @AID2)";
comm.Parameters.Clear();
comm.Parameters.AddWithValue("@ID2", ((Speaker)row).ID);
comm.Parameters.AddWithValue("@AID2", dataItem.Item1);
comm.ExecuteNonQuery();
}
HashSet<Tuple<String, String>> uniqueAnalysis = new HashSet<Tuple<String, String>>();
HashSet<Tuple<String, String>> uniqueRowName = new HashSet<Tuple<String, String>>();
string previous = "";
foreach (var row in rowS)
{
if (!((Speaker)row).Name.Equals(previous))
//.........这里部分代码省略.........