poco

EF4 Cast DynamicProxies to underlying object

与世无争的帅哥 提交于 2019-11-28 23:17:02
I'm using Entity Framework 4 with POCO template. I have a List where MyObject are dynamic proxies. I want to use the XmlSerializer to serialize this list, but I don't want them serialized as DynamicProxies but as the underlaying POCO object. I know about ContextOptions.ProxyCreationEnabled, but I do not want to use that. I just want to know how to cast a proxy object to it's underlaying POCO to serialize. Faced the same issue today and used Value Injecter to solve it. It's as simple as: var dynamicProxyMember = _repository.FindOne<Member>(m=>m.Id = 1); var member = new Member().InjectFrom

Some issues about Rob Conery's repository pattern

寵の児 提交于 2019-11-28 23:16:18
问题 Please read my update at the end of question after reading the answers: I'm trying to apply repository pattern as Rob Conery's described on his blog under " MVC Storefront ". But I want to ask about some issues that I had before I apply this design pattern. Rob made his own "Model" and used some ORM "LINQ to SQL or Entity Framework (EF)" to map his database to Entities. Then he used custom Repositories which gives IQueryable<myModel> and in these repositories he made sort of Mapping or

Entity Framework: Tracking changes to FK associations

偶尔善良 提交于 2019-11-28 21:59:16
I'm overriding SaveChanges on my DbContext in order to implement an audit log. Working with many-to-many relationships or independent associations is relatively easy as EF creates ObjectStateEntries for any changes to those kinds of relationships. I am using foreign key associations, and when a relationship between entities changes all you get is an ObjectStateEnty that says for example entity "Title" has "PublisherID" property changed. To a human this is obviously a foreign key in Title entity, but how do I determine this in runtime? Is there a way to translate this change to a "PublisherID"

Entity Framework 5 - How to generate POCO classes from existing database

喜夏-厌秋 提交于 2019-11-28 21:26:49
I am using VS 2012 and EF 5. I have an existing database that I want to create POCO classes from the existing database. I followed the steps to add an ADO.NET Entity Data Model to my project. I went through the wizard to use an existing database. It then created the edmx and tt files with the designer open. However, I want to create the POCO objects and use them. The Microsoft site states that the POCO Entity Framework Generator is obsolete and I should use the DBContext Generator. I can't figure out steps I use to generate the POCO classes. I only see the edmx designer. I really don't even

一种新的自动化 UI 测试解决方案 Airtest Project

社会主义新天地 提交于 2019-11-28 19:39:42
今天分享一个自动化UI测试工具airtest——一款网易出品的基于图像识别面向游UI测试的工具,也支持原生Android App基于元素识别的UI自动化测试。主要包含了三部分:Airtest IDE、Airtest(用截图写脚本)和 Poco(用界面UI元素来写脚本)。 来自Google的评价: Airtest 是安卓游戏开发最强大、最全面的自动测试方案之一。 它具备以下几个优势: 1.如果你是个小白,不想进行深度开发只想用作UI自动化测试,那么你完全可以用AirtestIDE这款IDE通过操作鼠标来生成并录制脚本,一键回放 2.支持在 Windows 和 macOS 上运行。基于图像识别的 Airtest 框架,适用于 Android 和 Windows 上的游戏,此外也支持Android native apps、Windows applications、iOS Support、Selenium Plugin 3.自动生成详细的HTML测试报告,附带了每个操作步骤的截图,方便迅速定位失败的测试点 4.提供了一种快速进行兼容性测试的方案,利用手机集群进行大规模自动化测试。 5.支持图像识别,可将图片元素作为参数进行校验操作 6.支持二次开发,只需要下载airtest的python第三方依赖库 多说无益,我们开始尝试使用Airtest进行Android APP测试 环境准备 1

EF CTP5 - Strongly-Typed Eager Loading - How to Include Nested Navigational Properties?

a 夏天 提交于 2019-11-28 17:51:57
Attempting to cutover our EF4 solution to EF CTP5, and ran into a problem. Here's the relevant portion of the model: The pertinent relationship: - A single County has many Cities - A single City has a single State Now, i want to perform the following query: - Get all Counties in the system, and include all the Cities, and all the State's for those Cities. In EF4, i would do this: var query = ctx.Counties.Include("Cities.State"); In EF CTP5, we have a strongly typed Include, which takes an Expression<Func<TModel,TProperty>> . I can get all the Cities for the County no problem: var query = ctx

Data Binding POCO Properties

主宰稳场 提交于 2019-11-28 17:45:38
问题 Are there any data binding frameworks (BCL or otherwise) that allow binding between any two CLR properties that implement INotifyPropertyChanged and INotifyCollectionChanged ? It seems to be it should be possible to do something like this: var binding = new Binding(); binding.Source = someSourceObject; binding.SourcePath = "Customer.Name"; binding.Target = someTargetObject; binding.TargetPath = "Client.Name"; BindingManager.Bind(binding); Where someSourceObject and someTargetObject are just

what is Entity Framework with POCO

大憨熊 提交于 2019-11-28 17:14:00
What is the benefit of using POCO? I don't understand the meaning of Persistence Ignorance, what does this mean? That the poco object can't expose things like Save? I can't wrap my head around this POCO that there's alot of buzz around. What is the difference with the EF generated entities and POCO? Dathan POCO stands for "Plain Old C# Object" or "Plain Old CLR Object", depending on who you ask. If a framework or API states that it operates on POCO's, it means it allows you to define your object model idiomatically without having to make your objects inherit from specific base classes.

What is the proper data annotation to format my decimal property?

我怕爱的太早我们不能终老 提交于 2019-11-28 11:56:36
I have a POCO with a decimal property called SizeUS. I would like to use data annotations to format the display of the decimal in a view. My SizeUS property is only displaying 2 decimal places in my view and I want it to display 4 decimal places. What is the proper data annotation to accomplish this ? [DisplayFormat( ? )] public decimal SizeUS {get; set;} [DisplayFormat(DataFormatString="{0:#.####}")] See Custom Format Strings for formats and DisplayFormatAttribute for examples 来源: https://stackoverflow.com/questions/20848969/what-is-the-proper-data-annotation-to-format-my-decimal-property

Linq expressions and extension methods to get property name

妖精的绣舞 提交于 2019-11-28 10:27:29
I was looking at this post that describes a simple way to do databinding between POCO properties: Data Binding POCO Properties One of the comments by Bevan included a simple Binder class that can be used to accomplish such data binding. It works great for what I need but I would like to implement some of the suggestions that Bevan made to improve the class, namely: Checking that source and target are assigned Checking that the properties identified by sourcePropertyName and targetPropertyName exist Checking for type compatibility between the two properties Also, given that specifying