我有一个数组:
string[] exceptions = new string[] { "one", two", "one_1", "three" };
Run Code Online (Sandbox Code Playgroud)
..我希望能够说:
var result = from c in myCollection
where not c.Property[3].Value.StartWith(exceptions)
select c;
Run Code Online (Sandbox Code Playgroud)
所以我希望myCollection过滤只显示那些在例外数组Property[3].Value中没有 StartWith值的记录.我知道StartsWith没有采集集合所以我不确定这是否可以通过LINQ实现.
这在LINQ中是否可行?!或者我是否想把我的问题变成LINQ解决方案?
编辑:我应该说,包含不是一个选项,因为我只想排除其属性以异常字符串开头的元素.
我不知道我想做什么是不可能的:或者我没有以正确的方式思考它.
我正在尝试构建一个存储库接口类,它接受泛型类型并将其用作大多数方法返回的基础,即:
public interface IRepository<T> {
void Add(T source);
T Find(int id);
}
Run Code Online (Sandbox Code Playgroud)
然后,这将由实际的存储库类继承,如下所示:
public class TestClientRepository : IRepository<ClientEmailAddress>, IRepository<ClientAccount> {
}
Run Code Online (Sandbox Code Playgroud)
例如,我想在ClientRepository中对几种不同的对象类型(ClientAccount,ClientEmailAddress等)执行操作; 但总的来说,所需的操作类型都是一样的.
当我尝试使用TestClientRepository时(在显式实现Interfaces之后),我看不到多个Find和Add方法.
有人可以帮忙吗?谢谢.
我们一直致力于VS2010和EF,围绕可扩展性和成本计算的各种讨论使我们开始考虑转向Mono.
我理解几乎所有的代码都是可用的,除了我们用于模型的EF(ASP.NET项目).
任何人都可以推荐一个易于使用的ORM,它将允许我们使用MySQL进行大量相同的映射(外键等)操作吗?我喜欢的一件事是EF建模的视觉元素,使得更改和查看关系变得非常简单.
我们有一个表,它通过数据库作业每约 15 分钟刷新一次,以使用来自各种来源的最新更改来保持前端更新。
过去为了读取这个表,调用了一个带有表提示 READPAST 的存储过程。我相信这样做的目的是确保表格可以按计划自由更新,但您也只能获得干净的数据供公众使用。
在带有 EF6 的 LINQ 中,有没有一种方法可以使用 TransactionScope 或其他一些机制来做到这一点?我知道没有明确支持开箱即用的表格提示,因此我正在寻找替代方案。我们想更多地使用 LINQ 和存储过程。更少(尤其是当他们所做的只是选择时)。
使用EWS托管API在C#中工作,我们无法有效地检索存储为内联附件的图像.
端点是显示带有内嵌图像的电子邮件,作为面板中完全形成的html页面.我们目前的代码:
string sHTMLCOntent = item.Body;
FileAttachment[] attachments = null;
if (item.Attachments.Count != 0)
{
attachments = new FileAttachment[item.Attachments.Count];
for (int i = 0; i < item.Attachments.Count; i++)
{
string sType = item.Attachments[i].ContentType.ToLower();
if (sType.Contains("image"))
{
attachments[i] = (FileAttachment)item.Attachments[i];
string sID = attachments[i].ContentId;
sType = sType.Replace("image/", "");
string sFilename = sID + "." + sType;
string sPathPlusFilename = Directory.GetCurrentDirectory() + "\\" + sFilename;
attachments[i].Load(sFilename);
string oldString = "cid:" + sID;
sHTMLCOntent = sHTMLCOntent.Replace(oldString, sPathPlusFilename);
}
}
}
Run Code Online (Sandbox Code Playgroud)
(来源:http: …
c# ×3
.net ×1
arrays ×1
comparison ×1
image ×1
inline ×1
interface ×1
linq ×1
mono ×1
nonblocking ×1
sql-server ×1