为什么MEAN.js applications'URL以#开头!(Why MEAN.js applications'URL start with #!)
我刚用MEAN.JS开始了我的第一个MEAN应用程序构建。 在发现了mean.js如何组织应用程序之后,我想知道为什么URL以
/#!/
开头。例如,对于我想要的登录页面:
http://example.com/login
代替:
http://example.com/#!/login
所以我查看了Express和Angular文档并没有发现它。 我还阅读了完整的MEAN.JS文档,但仍未找到任何内容。
在Angular的模块配置路由文件中,URL不是
#!
前缀#!
:users.client.routes.js:
... state('login', { url: '/login', templateUrl: 'modules/users/views/authentication/login.client.view.html' }). ...
所以我最后有两个问题:
- 为什么网址会这样开头? 这有什么好的做法吗?
- 如果这不是一件坏事,我该如何以及在哪里更改这些网址?
I just started my first MEAN application build with MEAN.JS. After discovering how mean.js organise the application, I wonder why URLs start with
/#!/
.For example for the login page I would like to have:
http://example.com/login
instead of:
http://example.com/#!/login
So I looked to the Express, and Angular docs and found nothing about it. I also read the full MEAN.JS docs but still found nothing.
On the Angular's modules configuration routes file, URLs are not prefix with
#!
:users.client.routes.js:
... state('login', { url: '/login', templateUrl: 'modules/users/views/authentication/login.client.view.html' }). ...
So I end up with two questions:
- Why the URLs start like this ? Is there a good practice behind this ?
- If it's not a bad thing, how and where can I change these URLs ?
原文:https://stackoverflow.com/questions/28569145
最满意答案
这两个查询在功能上是否相同?
如果通过等效表示最终结果,则可能是(取决于提供程序如何实现这些操作),区别在于您使用内存扩展的第二个查询。
我的意思是,查询中“AsNumerable()”的顺序是否会更改从客户端检索的数据项的数量,或者检索它们的方式?
是的,在第一个查询中,
Where
和OrderBy
将被转换为SQL ,Select
将在内存中执行。在第二个查询中,数据库中的所有信息都被带入内存,然后在内存中进行过滤和转换。
Categories
可能是IQueryable
,因此您将使用Queryable
类中的扩展。 此版本的扩展接收Expression
作为参数,这些表达式树允许将代码转换为sql查询。
AsEnumerable()
将对象作为IEnumerable
返回,因此您将使用Enumerable
类中直接在内存中执行的扩展。Are this 2 queries functionally equivalent?
If by equivalent you means to the final results, then probably yes (depending how the provider implements those operations), the difference is in the second query you are using in-memory extensions.
I mean, does the order of "AsNumerable()" in the query change the number of data items retrieved from the client, or the way they are retrieved?
Yes, in the first query,
Where
andOrderBy
will be translated to SQL and theSelect
will be executed in memory.In your second query all the information from the database is brought to memory, then is filtered and transformed in memory.
Categories
is probably anIQueryable
, so you will be using the extensions inQueryable
class. this version of the extensions receive aExpression
as parameter, and these expression trees is what allows transform your code to sql queries.
AsEnumerable()
returns the object as anIEnumerable
, so you will be using the extensions inEnumerable
class that are executed directly in memory.
相关问答
更多-
我会做 var ids = from o in dbcontext.Orders where o.ID==1 select new { ID = o.ID }; var names = from i in ids.AsEnumerable() select new Order { Name = GetName(i.ID) }; 即在数据库中尽可能多地进行查询,然后仅在C#中执行ID到名称的转换。 I'd do var ids = from ...
-
AsEnumerable()。取(AsEnumerable().Take)[2022-08-12]
是的,这是从数据表中获取前N行的正确方法。 使用CopyToDataTable扩展从查询结果创建新数据表: DataTable dt = dtResult.AsEnumerable() .Take(n) .CopyToDataTable(); Yes, this is a correct way to take first N rows from your data table. Use CopyToDataTab ... -
调用AsEnumerable( )不执行查询,枚举它。 IQueryable是允许LINQ to SQL执行其魔术的界面。 IQueryable实现IEnumerable所以当你调用AsEnumerable() ,你正在改变被调用的扩展方法,即从IQueryable方法到IEnumerable方法(即在这个特定情况下,从LINQ to SQL到LINQ to Objects )。 但是你并没有执行实际的查询,只是改变它将如何执行。 要强制查询执行,您必须调用ToList() 。 Calling AsEnum ...
-
AsEnumerable的原因是 当序列实现IEnumerable(T)时,AsEnumerable(TSource)(IEnumerable(TSource))可用于在查询实现之间进行选择,但也有一组不同的公共查询方法 所以当你以前调用Where方法时,你正在从IEnumerable.Where调用另一个Where方法。 那个Where语句是为了将LINQ转换为SQL,新的IEnumerable在哪里使用IEnumerable,枚举它并产生匹配项。 这就解释了为什么你看到不同的SQL被生成。 在将第二个版 ...
-
LINQ查询比较(LINQ Queries Comparison)[2023-09-23]
第二个更好,第一个做一个选择然后进行过滤,这意味着它必须先从数据库中获取数据,然后将其转换为User对象,然后进行过滤。 第二个将在DB端进行查询,然后将其转换为User对象 可以通过将选择移动到ToList()之前来修复第一个 The Second one is better, the first 1 does a select then does filtering, meaning it has to get the data from the database first to turn it in ... -
放入“AsEnumerable”时,LINQ“不支持方法连接”消失了(LINQ “Method Join Not Supported” gone when put “AsEnumerable”)[2022-06-18]
AsEnumerable强制将Join语句执行到LINQ to Objects中。 因此,来自RC_CampaignHubSpokeTbl和RC_CampaignTbl所有数据都将从WCF获取,然后在您的应用程序中组合在一起。 这是必要的,因为WCF调用不支持连接。 要优化您的查询,您可以执行以下操作: que = From CHS In ent.RC_CampaignHubSpokeTbl.AsEnumerable() Join Cam In ent.RC_CampaignTbl.Where( ... -
你的理解是正确的。 在调用AsEnumerable ,数据源不能再被查询,并回到简单的“给我所有”模式,这意味着所有的数据都被传输到客户端,并且任何进一步的操作都在本地完成。 这也是查询不能像编写的那样工作的原因:为了使其工作,您在LINQ方法中使用的所有表达式必须可转换为数据源所能理解的任何语言 - 并且由于它是查询提供程序翻译的责任,你也将受到任何程序支持的限制。 在这种特定情况下(假设EF),可以通过手动将属性访问替换为规范函数TruncateTime来修复查询以在可查询模式下工作: .Where(m ...
-
这两个查询在功能上是否相同? 如果通过等效表示最终结果,则可能是(取决于提供程序如何实现这些操作),区别在于您使用内存扩展的第二个查询。 我的意思是,查询中“AsNumerable()”的顺序是否会更改从客户端检索的数据项的数量,或者检索它们的方式? 是的,在第一个查询中, Where和OrderBy将被转换为SQL , Select将在内存中执行。 在第二个查询中,数据库中的所有信息都被带入内存,然后在内存中进行过滤和转换。 Categories可能是IQueryable ,因此您将使用Queryable ...
-
AsEnumerable如何运作?(How AsEnumerable works?)[2022-01-10]
它们是不同的扩展方法。 一个是DataTableExtensions.AsEnumerabl e和其他是Enumerable.AsEnumerable They are different Extension methods. One is DataTableExtensions.AsEnumerable and other is Enumerable.AsEnumerable -
.ToList()将在内存中构建一个新的List
并将所有对象存储在其中。 那是不必要的工作; 你应该调用.AsEnumerable() 。 通常,只有在需要多次迭代时(并且只在查询链的末尾.ToList()才应调用.ToList() )。 .ToList() will build a new List in memory and store all of the objects in it. That is needless work; you should call .AsEnumerable ...