Setting LLBLGen Pro TypedList Properties to Nullable type? - nullable

I am using LLBLGen Pro 2.6. In the designer, you can easily set a field in an entity to be a .Net nullable type. When you have those same fields in a Typed List, there doesn't seem to be a way to set that same field to be a .Net nullable type. Is anyone aware if and how to do that?
Thanks!

The reason for this is that typed list are using the entities that you have already mapped in the Entities section.
Regards

Related

AutoMapper is not mapping my byte array fields

I have a pretty straightforward POCO that contains a property called Image of type byte[]. I'm finding that if this field is set to null, and the Entity Framework object I'm mapping to already has a value for the Image property, the EF object value is not being set to null after I call Mapper.Map.
Is there something specific I should be doing to force AutoMapper to do this, or should I be doing this manually?
Using version 2.2.1 of AutoMapper.
Thanks,
Gary
I realized I was actually on a pre-release version of 2.2.1. After upgrading to the latest version this issue appears to have disappeared. If anyone else finds this happening you may want to check this as a possible solution.
Try using the AllowNullCollections configuration option:
Mapper.Configuration.AllowNullCollections = true;

Self Tracking entities and the mysterious ChangeTracker_ChangeTrackingEnabled datatable column

I'm using Self Tracking Entities that implements IObjectWithChangeTracker with the last Entity Framework RC available as a Nuget. The target database is PostgreSQL. I'm also using Code First fluent API to construct the model and LINQ to Entity for querying the database.
To my surpise, a simple SELECT query on the entity generates a SQL query with a mysterious column ChangeTracker_ChangeTrackingEnabled that does not exist in the datatable ! I do not understand this behavior as it seems to me that the EntityTypeConfiguration derived class maps the entity properties to the datatable columns in its constructor.
Is there a way to disable this behavior or at least tell which column should be mapped by the change tracker ?
For that purpose, Context.Configuration.AutoDetectChangesEnabled = false or calling IsConcurrencyToken() mapping in the EntityTypeConfiguration derived object does not help.
Any help appreciated.
TIA.
You must inform EF about every public property you want to avoid in mapping by either marking property with NotMapped attribute or by using Ignore in fluent API.
Btw. as I know STEs are not designed to be used with code first or DbContext API.

ASP.NET MVC nullable field of a model

I'm making a Web Page with MVC and I would like to know if it's possible to set a field as nullable, I mean, the opposite of Required, because I want it to be an optional field.
Thank you.
All object types can be nullable, i.e. optional, for value types you can use either the type? notation or explicitly with Nullable<type>. If you don't provide a value to the ModelBinder for that property then it will receive NULL.
If you omit the [Required] attribute on the optional field in the model this will have the desired effect.

Entity Framework, Oracle, DevArt, Context#ExecuteStoreQuery: System.Int32 constructed as System.Double?

I have an Entity-class having a Property of type Int32: on generating DDL using DevArt for ORACLE a NUMBER(10) column is generated. Reading and writing instances works flawlessly.
However, on fetching instances of this Entity-class sending a custom query to ExecuteStoreQuery on the ObjectContext this Property seems to be returned as System.Double, as such constructing the instances fails.
Can I hint DevArt to construct System.Int32?
Thank you.
Bart
The reason is the fact that OracleDataReader, which is used in the ExecuteStoreQuery method, has type mapping different from the one used in the Entity Framework provider.
I recommend you to use NumberMappings, I suppose you will need to map Number(10) to Int32: Number Mappings=((NUMBER,10,10,System.Int32). These changes should be persisted to the model connection string (they are duplicating the default EF mapping rules, it is necessary for the OracleDataReader from ExecuteStoreQuery).
Please let us know if the problem persists.

Entity Framework - Creating a strongly typed projection in the designer

I am trying to create a strongly typed projection entity "ProjectedPersons" via the designer in the Entity Framework.
I am using POCO classes and have seperated them out into seperate projects.
I keep getting an error:
error 3027: No mapping specified for the following EntitySet/AssociationSet - ProjectedPersons.
How can I remove this error. I only want to use the entity for projections not mapping to the database.
Thanks
If you are using the object only for projections - I would recommend creating it as a complex type instead. You get much of the same features without a lot of the contextual overhead that is inherent to an entity. I believe an entity is fully expecting to be mapped to a database feature in some respect - hence your error.
If you want to define projection in designer you must use QueryView (projection query defined directly in the designer and mapped to the new readonly entity) - that is the feature which must be manually defined directly in XML (MSL part) not in the designer. Otherwise you must do projection manually in Linq query. For linq query you don't need to create entity in the designer. You can use any class which is not mapped in the designer.
The QueryView was the solution. I found a helpful example.
http://msdn.microsoft.com/en-us/magazine/ee336312.aspx

Resources