poco

EF CTP4 lazy loading not playing ball

旧时模样 提交于 2019-12-24 07:03:19
问题 I'm using the CTP4 code first EF framework, but I'm having problems getting lazy loading to work. Reading up on it, it should be simple, but it's just not public class Folder { public int Id { get; set; } public string Name { get; set; } public int? ParentFolderId { get; set; } public virtual IList<Folder> ChildFolders { get; set; } } In the model configuration: HasMany(f => f.ChildFolders).WithOptional().HasConstraint((child, folder) => child.ParentFolderId == folder.Id); However, when I do

Reloading navigation properties after detaching a new object

≡放荡痞女 提交于 2019-12-24 05:52:58
问题 I am using Entity Framework with POCO objects and have the following scenario: I create a new parent object and add a child object to it. Then I save changes and detach the parent object. At this moment its children collection gets empty. parent = new Parent() { label = "Test" }; parent.Children.Add(new Child() { label = "Test" }); context.Parents.AddObject(parent); context.SaveChanges(); context.Detach(parent); When I reattach the parent object to a different context, I have to explicitly

Customized mapping in poco of Entity framework

最后都变了- 提交于 2019-12-24 03:28:05
问题 Sometimes i would like to serialize dynamic properties to one field in database and lazy deserialize field to dynamic properteis in object view, see following in object view: public IDictionary<string, string> _properties; public IDictionary<string, string> Properties { get { if (_properties == null) { _properties = new Dictionary<string, string>(); Deserialize(_properties, PropertyString); } return _properties; } } I know how to do it in ef 3.5. I add entity self intercept function when

Generate POCO classes and the mapping for an existing database using Entity Framework

限于喜欢 提交于 2019-12-24 00:44:00
问题 Is it possible to auto generate the POCO classes and the mapping with the database defined separately using Fluent API (instead of annotations) for an existing database? Instead of coding all these entity classes manually, I find it easier if they are auto generated and then I can change them as required if the names are not incorrect (plural or singular) or the some of the relationships are not correctly mapped etc. This will save lot of time for me compared to coding all the entity classes

Conversion from POJO to POCO

隐身守侯 提交于 2019-12-24 00:38:21
问题 I'm creating a Compact Framework 3.5 application, which is the client side of an older Java webapp. The communication protocol between both sides is REST+JSON. Serialization of the POJOs to JSON is not a matter since the POJOs already exist. But instead of rewriting from scratch a C# version of all the POJOs sources to be able to deserialize the JSON client-side, I would prefer a generation using some tools. Or at least, do the conversion manually with a "standardized" method. Do you know

Upload to Azure Blob using SAS and REST

时间秒杀一切 提交于 2019-12-23 22:27:47
问题 I'm having trouble writing to an Azure Block Blob from C++ using a SAS (Shared Access Signature). I'm using the Blob REST API and Poco. The HTTP request returns error 404 (resource does not exist), but I can't figure out what I'm doing wrong. I generate the SAS on the server in C# like this (seems to work fine): CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); CloudBlobClient blobClient = storageAccount

select certain fields from dbset<t>

走远了吗. 提交于 2019-12-23 16:43:52
问题 I am using EF4.1, and for performance issues I need to select only a few fields from a DbSet which is mapped to a view on the sql server. Any ideas about how to do that? so selecting fields from Customer would return the below error. var result = context.Customers.Select(c => new Customer{ Name = c.Name,Age = c.Age}).ToList(); The entity or complex type 'Customer' cannot be constructed in a LINQ to Entities query. at System.Data.Objects.ELinq.ExpressionConverter.CheckInitializerType(Type type

How to make POCO work with Linq-to-SQL with complex relationships in DDD

人走茶凉 提交于 2019-12-23 13:15:17
问题 I am struggling to find a way to make POCOs work with Linq-to-Sql when my domain model is not table-driven - meaning that my domain objects do not match-up with the database schema. For example, in my domain layer I have an Appointment object which has a Recurrence property of type Recurrence. This is a base class with several subclasses each based on a specific recurrence pattern. In my database, it makes no sense to have a separate AppointmentRecurrences table when there is always a one-to

How to map parent column in EF 4.1 code first

若如初见. 提交于 2019-12-23 12:37:16
问题 In my project I have following DomainModel. public class Login { public Guid Id { get; set; } public Login CreatedBy {get; set; } } I am using fluent configuration as below: modelBuilder.Entity<Login>() .HasKey(x => x.Id) .ToTable("Login"); modelBuilder.Entity<Login>() .HasOptional(x => x.CreatedBy) .WithMany() .HasForeignKey(x => x.CreatedBy); My code in repository to get all Logins data is as below: return from d in Db.Logins.Include("CreatedBy") select d; When I execute the code I am

Issue after uploading to azure with EF Unable to load the specified metadata resource error

元气小坏坏 提交于 2019-12-23 12:11:53
问题 I am working with ASP.net MVC5 Application and with EF 5 Model first approach. But also used poco classes, which is in another C# project called "Entity". I am having multi-tier architecture where Edmx file is in DAL layer and BAL is having reference of it and BAL and Entity Project are referenced in main web project. Everything works well but after setting up the database and project on Azure when my site tries to connect database it throws below error "MetadataException: Unable to load the