poco

Entity Framework 4 / POCO - Where to start? [closed]

扶醉桌前 提交于 2019-11-26 19:16:29
I've been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although when using entities it has been on a Entity/Table 1-1 relationship - ie not much different than L2SQL) I've been doing a lot of reading about Inversion of Control, Unit of Work, POCO and repository patterns and would like to use this methodology in my new applications. Where I'm struggling is finding a clear, concise beginners guide for EF4 which doesn't assume knowledge of EF1. The specific questions I need answered are: Code first / model first? Pros/cons in regards to EF4 (ie what happens if I

What is POCO in Entity Framework? [closed]

扶醉桌前 提交于 2019-11-26 19:07:14
问题 I just started learning POCO but cannot understand its use and advantage. Even following link of stackoverflow did not help me. what is Entity Framework with POCO Can anybody explain the usage of POCO with a simple example? 回答1: POCOs(Plain old CLR objects) are simply entities of your Domain. Normally when we use entity framework the entities are generated automatically for you. This is great but unfortunately these entities are interspersed with database access functionality which is clearly

Generate POCO classes in different project to the project with Entity Framework model

佐手、 提交于 2019-11-26 18:41:42
I'm trying to use the Repository Pattern with EF4 using VS2010. To this end I am using POCO code generation by right clicking on the entity model designer and clicking Add code generation item. I then select the POCO template and get my classes. What I would like to be able to do is have my solution structured into separate projects for Entity (POCO) classes and another project for the entity model and repository code. This means that my MVC project could use the POCO classes for strongly typed views etc and not have to know about the repository or have to have a reference to it. To plug it

Poco Logger demo

风流意气都作罢 提交于 2019-11-26 18:32:37
// PocoThreadLoggerTest.cpp #include <cstdlib> #include <iostream> #include < string > #include " Poco/Thread.h " #include " Poco/ThreadTarget.h " #include " Poco/Runnable.h " #include " Poco/Logger.h " #include " Poco/PatternFormatter.h " #include " Poco/FormattingChannel.h " #include " Poco/ConsoleChannel.h " #include " Poco/FileChannel.h " #include " Poco/Message.h " #include " Poco/Random.h " static Poco::Logger * pLogger; class MyRunnable : public Poco::Runnable { private : std:: string _name; Poco::Random _rnd; public : void setName(std:: string name) { _name = name; } void run() { for (

Poco 模拟tree命令

杀马特。学长 韩版系。学妹 提交于 2019-11-26 18:32:23
tree.cpp // tree.cpp // After // poco/1.4/Foundation/samples/dir/src/dir.cpp // #include " Poco/DirectoryIterator.h " #include " Poco/File.h " #include " Poco/Path.h " #include " Poco/DateTimeFormatter.h " #include " Poco/DateTimeFormat.h " #include " Poco/Exception.h " #include <iostream> using Poco::DirectoryIterator; using Poco::File; using Poco::Path; using Poco::DateTimeFormatter; using Poco::DateTimeFormat; int recuDir(std:: string dir, std:: string preSpc) { try { DirectoryIterator it(dir); DirectoryIterator end; preSpc += " " ; std::cout << preSpc << ' | ' << " - " << ' . ' << std:

Poco::Timer 定时器demo

拜拜、爱过 提交于 2019-11-26 18:32:22
timer.cc #include <cstdlib> #include <iostream> #include <Poco/Timer.h> #include <Poco/Thread.h> using Poco::Timer; using Poco::TimerCallback; using Poco::Thread; class TimerExample { public : void onTimer(Timer& timer) { std::cout << " onTimer called. " << std::endl; } }; // === FUNCTION ====================================================================== // Name: main // Description: main function // ===================================================================================== int main ( int argc, char * argv[] ) { long totalTime = 2000 , startInterval = 0 , periodicInterval = 0 ;

Poco Exception例子

社会主义新天地 提交于 2019-11-26 18:31:07
Poco Exception提供的宏挺方便的。。 #include " Poco/Exception.h " #include <iostream> POCO_DECLARE_EXCEPTION( , MyException, Poco::Exception ) POCO_DECLARE_EXCEPTION( , MyFatalException, Poco::Exception ) POCO_IMPLEMENT_EXCEPTION( MyException, Poco::Exception, " Something really bad happened... " ) POCO_IMPLEMENT_EXCEPTION( MyFatalException, Poco::Exception, " Something really really bad happened... " ) void reallyBad () { throw MyException(); } void reallyReallyBad () { throw MyFatalException(); } int main( void ) { try { reallyBad(); } catch ( MyException& ex ) { std::cout << ex.displayText() << std:

Adding [DataMember] [DataContract] attributes in Entity Framework POCO Template

六眼飞鱼酱① 提交于 2019-11-26 16:26:54
问题 I would like some help adding in a POCO .tt Entity Framework template Attributes to support WCF serialization and if its possible how to add namespace usings to each entity. Thank you. 回答1: You need to open your model1.tt file (or whatever it's called in your project), and add a few things. Locate these lines of code (line 34, in my case): // Emit Entity Types foreach (EntityType entity in ItemCollection.GetItems<EntityType>().OrderBy(e => e.Name)) { fileManager.StartNewFile(entity.Name + "

How to add validation to my POCO(template) classes

泄露秘密 提交于 2019-11-26 14:38:17
So I used this tutorial to generate my poco classes which I am to use throughout my aplication.. the problem is that Im not supposed to modify the generated cs files cause they get autoregenerated... How do I add attributes like [Required] and stuff like that?? please help You can't add it directly (unless you modify T4 template to create them for you) but you can try to use trick introduced in ASP.NET dynamic data. All POCO classes are defined as partial. So lets define your partial part: using System.ComponentModel.DataAnnotations; [MetadataType(typeof(MyClassMetadata))] public partial class

Is it possible to prevent EntityFramework 4 from overwriting customized properties?

天大地大妈咪最大 提交于 2019-11-26 13:59:47
问题 I am using EF 4 Database first + POCOs. Because EF has no easy way to state that incoming DateTimes are of kind UTC, I moved the property from the auto-generated file to a partial class in another file. private DateTime _createdOn; public virtual System.DateTime CreatedOn { get { return _createdOn; } set { _createdOn = (value.Kind == DateTimeKind.Unspecified) ? _createdOn = DateTime.SpecifyKind(value, DateTimeKind.Utc) : value; } } However, now every time I update the model, the automated