Tag: find

如果:XElement存在,否则创建新的

我的XML文件: 0 0 首先,我需要检查xml .element(“player”).attribute(“name”)是否存在用户名“Tardis”。 如果没有,我需要创建它,杀戮和死亡为零。 如果确实如此,我需要阅读杀戮和死亡并将它们设置为变量。 我一直在使用XElement尝试这样做..谢谢! 用于编写XML的代码: public static string username = “Tardis”; public static int kills = 0; public static int deaths = 0; …….. XElement Players = new XElement( “SimpleKD”, new XElement(“player”, new XAttribute(“name”, username), new XElement(“kills”, kills), new XElement(“deaths”, deaths)));

DBContext Find with Includes – 其中lambda带有主键

我正在编写一个通用存储库来使用DBContext与EF进行交互。 我有一个通用的Get()方法,它接收主键值并返回实体: public class DALRepository : IDisposable, IGenericRepository where DALEntity : class { private IDbSet dbSet; private NWEntities context; public DALRepository() { context = new NWEntities(); context.Configuration.LazyLoadingEnabled = false; dbSet = context.Set(); } 这是一个简单的get方法 – 只适用于PK – 正是我想要的。 public DALEntity Get(string ID) { return dbSet.Find(ID); } 我现在想要改变它以允许消费者传递包含列表 – 以及只返回他们可以请求返回订单的客户。 这是我遇到麻烦的地方。 如果我这样做: public DALEntity Get(string ID, […]

如何搜索多维数组?

在C#中, Array.Find(arrayName, value); 搜索一维数组。 反正有多维数组(例如myArray[,,] )吗?

在列表中查找int的索引

有没有办法从列表中获取int的索引? 寻找类似list1.FindIndex(5)东西,我想在列表中找到5的位置。

如何使用entity framework的Find方法查找List ,将Array作为参数传递?

我想知道如何使用Entity Framework的Find方法将Array( object[] )作为参数找到List ? 我想通过Primary Key查找所有数据。 我首先填写一个列表,其中包含我将用作参考的所有PK: List lCodigoServicos = new List(); foreach (ServicosSelecionadosModelView servicoSelecionado in lServicos.FindAll(s => !string.IsNullOrEmpty(s.selecionado) && s.selecionado.ToLower() == “on” )) lCodigoServicos.Add(servicoSelecionado.servico.SerId); 在填写我的PK列表后,我尝试通过PK查找所有数据 var lServicosInformados = db.Servicos.Find(lCodigoServicos.ToArray()); 当我尝试这个时,我收到以下错误: The specified parameter type ‘System.Int32[]’ is not valid. Only scalar types, such as System.Int32, System.Decimal, System.DateTime, and System.Guid, are supported. 请与我们分享如何正确地做到这一点。 谢谢。 解决方案如下所述,正确的解决方案是: […]

突出显示richtextbox中所有搜索到的单词

在我的RichtextBox ,如果我写的如下。 这是我的笔, 他的笔是美丽的。 现在我搜索单词“is”然后输出如下。 所有“是”应该突出显示。 此致,Khilen

C#:在Word中搜索文本并获取结果的范围

我可以通过以下方式在Word文件中找到文本: Word.Range range = wordApp.ActiveDocument.Content; Word.Find find = range.Find; find.Text = “xxx”; find.ClearFormatting(); find.Execute(ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); 这告诉我是否找到了文本。 但我需要找到的文字片段。