提取两个字符PowerShell之间的所有字符串(extract all the strings between two characters powershell)
以下是两个字符。 1. {{2.}}我试图在以下文件中找到这些字符之间的所有字符串。
<add key="CSDFG_SqlServerFailOverInterval" value="{{environment}}"/> <add key="CSDFG_JobResetInterval" value="600000"/> <add key="FileTypeFilter" value="{{filetype}}"/>
我正在使用下面的PowerShell命令,
$x = C:\app.config $s = Get-Content $x $prog = [regex]::match($s,'{{([^/)]+)}}').Groups[1].Value write-host $prog
而我的输出只是一个字符串。 它并没有拉动所有的琴弦。 有人可以建议我如何得到所有的字符串。 提前致谢。
Following are the two characters. 1. {{ 2. }} I'm trying to find all the strings between these characters in the following file.
<add key="CSDFG_SqlServerFailOverInterval" value="{{environment}}"/> <add key="CSDFG_JobResetInterval" value="600000"/> <add key="FileTypeFilter" value="{{filetype}}"/>
and I'm using following powershell commands,
$x = C:\app.config $s = Get-Content $x $prog = [regex]::match($s,'{{([^/)]+)}}').Groups[1].Value write-host $prog
and my output is just one string. it is not pulling all the strings. Can someone please suggest me how to get the all the strings. Thanks in advance.
原文:https://stackoverflow.com/questions/36828277
最满意答案
实际上你并没有被迫使用你加载的实体的导航属性,你可以使用你的第二个(和工作)解决方案与这样的额外过滤器:
new Context().Elements.Where(i => i.Pan.Id == myPan.Id && <my_filter>).Include(i => i.Tray).ToList();
或者如果您愿意,只需插入哪个相同:
new Context().Elements.Where(i => i.Pan.Id == myPan.Id).Where(i => <my_filter>).Include(i => i.Tray).ToList();
Actually you are not forced to use the navigation properies of your loaded entity, you can utilize your second (and working) solution with additional filter like this:
new Context().Elements.Where(i => i.Pan.Id == myPan.Id && <my_filter>).Include(i => i.Tray).ToList();
or if you prefer, with just inserted
Where
which is the same:new Context().Elements.Where(i => i.Pan.Id == myPan.Id).Where(i => <my_filter>).Include(i => i.Tray).ToList();
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
你可以结合@ arthuro的解决方案和反思来调用所有的获得者。 像这样的东西: public static
T findEager(EntityManager em, Class type, Object id) { T entity = em.find(type, id); for (Field field: type.getDeclaredFields()) { OneToMany annotation = field.getAnnotation(OneT ... -
实际上你并没有被迫使用你加载的实体的导航属性,你可以使用你的第二个(和工作)解决方案与这样的额外过滤器: new Context().Elements.Where(i => i.Pan.Id == myPan.Id &&
).Include(i => i.Tray).ToList(); 或者如果您愿意,只需插入哪个相同: new Context().Elements.Where(i => i.Pan.Id == myPan.Id).Where(i => ).In ... -
解决方法: categoryRepository.Get(x => x.Id == categoryId, x => x.Products.Select(p => p.Product)); 这篇EF博文有很多帮助! Solved by doing: categoryRepository.Get(x => x.Id == categoryId, x => x.Products.Select(p => p.Prod ...
-
如何首先加载与实体框架代码的多对多关系?(How to eagerly load a many to many relationship with the entity framework code first?)[2021-12-05]
你需要一个Include()查询来表明你想要加载相关的Course实体: var allStudents = context.Students.Include( s => s.Courses); 还要确保你有一个 using System.Data.Entity; 在你的代码文件中,所以你可以使用强类型的Include()扩展方法。 You want an Include() query to indicate that you want to eagerly load the related Cour ... -
急切地从Hibernate / JPA加载延迟项目并更正对象计数(Eagerly load lazy items from Hibernate/JPA and correct object counts)[2022-07-26]
我认为这是根据规范(不幸的是)。 见JPA 2.1,ch。 4.4.5.3“获取联接”: 以下查询返回一组部门。 作为副作用,即使它们不是显式查询结果的一部分,也会检索这些部门的关联员工。 [...] SELECT d FROM Department d LEFT JOIN FETCH d.employees WHERE d.deptno = 1 [...]因此,例如,如果部门1有五名员工,则上述查询将返回对部门1实体的五个引用。 I think this is according to spec (un ... -
实体框架 - 使用存储过程热切地加载对象图(Entity Framework - Eagerly load object graph using stored procedures)[2023-02-06]
它可以以相当简单的方式完成,但需要一些手动操作。 这是一篇关于使用多个结果集处理存储过程的MSDN文章 ,其中显示了代码优先和数据库优先方法。 例: 加载实体B proc: create proc dbo.Get_EntityB_by_EntityAId( @aId int ) as select distinct b.EntityBId , b.Description from EntityA a left outer join EntityB b on a.P ... -
Hibernate Criteria:急切地加载ManyToMany集合(Hibernate Criteria: Eagerly load ManyToMany collection)[2021-11-30]
使用LAZY设置获取集合并: List list = criteria.list(); Hibernate.initialize(list); 这将立即初始化它,仅适用于此情况。 Get the collection with the LAZY setting and : List list = criteria.list(); Hibernate.initialize(list); This will initialize it immediately, only for this case. -
如果你的应用程序不复杂,但更多的是CRUD性质,那么这个答案并不那么重要。 但是,如果您的业务领域存在复杂性,那么这很重要。 它与关注点的分离和构建更强大的应用程序有关: 一层中的更改不应强制另一层中的更改。 一层中的设计决策/约束不应强制在其他层上。 一个典型的例子是使用Entity Framework或其他ORM映射器。 如果您要设计一个仅专注于业务领域的实体,那么它很可能以一种方式查看(例如使用适当的封装等)。 但是从实体框架的角度来看,您会做出一些牺牲以允许EF跟踪和处理实体。 向用户展示实体时,您 ...