entities

Linq to Entities中的Datetime类型转换

雨燕双飞 提交于 2021-01-13 08:53:50
使用JavaScriptSerializer将Ado.net Entity Framework的实体转换为JSON。不过JavaScriptSerializer在序列化Datetime类型的处理有些特别: DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0, DateTimeKind.Utc); DateTime dt=(DateTime)obj ; return string.Format(" new Date({0}) ", (long) ((dt.ToUniversalTime().Ticks - time.Ticks) / 0x2710L)) 生成的是类似"\/Date(1271729248060)\/"的字符串,而不是通常的时间格式。虽然这种做法有关于全球化和减少ajax传输量的考虑,但是在大多数的本地化应用中,我们其实只需要传递通常的时间格式字符串就行了。 虽然在Linq to Entities里不支持ToString()等类型转换,但是我们可以使用AsEnumerable()先将Linq to Entities的结果转换为IEnumerable,再使用ToString()方法把时间字段转化成String。 var list = ctx.UserInfo.Select(u => new { u.Id, u.Guid, u

Retaining entity in xslt stylesheet output without using character-map

久未见 提交于 2020-06-17 13:12:25
问题 Where did we go wrong? When I process this xml with xslt 2 on saxon he: <data> <grab>Grab me and print me back "</grab> </data> using this stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="/"> <xsl:apply-templates select="/data/grab"/> </xsl:template> <xsl:template match="/data/grab"> <node><xsl:value-of select="text()"/></node> </xsl:template> </xsl:stylesheet> I get this output: <?xml version="1.0" encoding="UTF-8"?><node>Grab

Why not use an IoC container to resolve dependencies for entities/business objects?

旧时模样 提交于 2020-01-26 05:15:21
问题 I understand the concept behind DI, but I'm just learning what different IoC containers can do. It seems that most people advocate using IoC containers to wire up stateless services, but what about using them for stateful objects like entities? Whether it's right or wrong, I normally stuff my entities with behavior, even if that behavior requires an outside class. Example: public class Order : IOrder { private string _ShipAddress; private IShipQuoter _ShipQuoter; public Order(IOrderData

PHP array and htmlentities

守給你的承諾、 提交于 2020-01-26 02:44:34
问题 $_POST= Array ( [0] => aaa@gmail.com [1] => bbb [2] => ccc [3] => ddd [4] => eee [5] => fff [6] => ggg [7] => hhh [8] => iii [9] => jjj [10] => 31 [11] => k ) foreach($_POST as $key => $val){ for ($key = 0; $key <= 9;$key++){ $_POST2[$val] = htmlentities($_POST[$val]); } } } This is my code and what I was trying to do was that I wanted to split the $_POST array into $key and $val . Then I wanted to tell the program that as the $key goes up by 1 , put htmlentities() around the $val . Can you

Symfony2 doctrine:generate:entities throw Syntax Error?

隐身守侯 提交于 2020-01-23 06:04:10
问题 when i am using the symfony2 shell and trying to run doctrine:generate:entities [MyBundle] --path='src' or doctrine:generate:entities [MyBundle] i got this error [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_CLOSE_CURLY_BRACES, got '@' at position 255 in property so please any solutions ?? thanks in advance 回答1: I've encountered this error also. It's just a simple typo in one of your Entity annotations. A quick check of your entities will reveal something like this: /** *

How to make all entities access:internal instead of public in EDMX?

♀尐吖头ヾ 提交于 2020-01-11 04:42:07
问题 I'd like my Entity Framework model to generate entities with internal access modifier, instead of public . I use the EF model in a library and I want only a single class (some controller) to be accessible from outside. Is there any simple way to make the EF model generation use internal modifer instead of public , including model regeneration on update? 回答1: It's very much like the anwer I got on a similar question. But in your case you want to customize the access modifier of the classes,

Aggregate root invariant enforcement with application quotas

ぐ巨炮叔叔 提交于 2020-01-05 04:57:13
问题 The application Im working on needs to enforce the following rules (among others): We cannot register a new user to the system if the active user quota for the tenant is exceeded. We cannot make a new project if the project quota for the tenant is exceeded. We cannot add more multimedia resources to any project that belongs to a tenant if the maximum storage quota defined in the tenant is exceeded The main entities involved in this domain are: Tenant Project User Resource As you can imagine,

Recover values select imput related entities doctrine symfony 2

一笑奈何 提交于 2020-01-05 04:03:16
问题 I'm trying to create a form based on my related entities in doctrine by Symfony 2. I have different entities: Tematica, Personal, Hilo, Consultante, Consulta, Consulta_Asignatura and Asignatura. I reach to persist all my data, nevertheless have some problems with entities Hilo Personal and Tematica. In my form need to show select imput, it should have all "Enunciado" rows and later recover Email of selected option in this select input. I'll share my code, I hope somebody can help my. class

Many to Many, One to Many or Many to One

笑着哭i 提交于 2020-01-04 14:19:47
问题 I am trying to get my head around Doctrine 2 ORM relationships, I thought I had the hang of it but after reading a few symfony cookbook entries, I suspect I am actually a little confused. I currently have a system where a template can contain multiple modules (including more than one of each type) and multiple templates can use the same module. I thought that this would warrant a ManyToMany relationship and indeed looking at my table, it seems to work quite well. However I realised as I was

LINQ to Entities Join on DateTime.DayOfWeek

半城伤御伤魂 提交于 2020-01-03 09:23:09
问题 Imagine two tables: Shifts, RANK_S_DAY. Shifts contains a ShiftDate column which is DateTime and RANK_S_DAY has a DayOfWeek column. I need to join (int)ShiftDate.DayOfWeek equals DayOfWeek . I understand why it won't work, but I'm not quite sure how I can change it. The Exception is: The specified type member 'DayOfWeek' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported. As I understand it, LINQ can't translate (int