Facets from the MetadataWorkspace not requestable, MaxLength

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

Facets from the MetadataWorkspace not requestable, MaxLength

Post by HCRoman » Wed 12 Aug 2009 06:06

Hi devart team,

I tried your EntityFramework-Mapper for Oracle and at a first look it works great! :D :D

I have some question:
Why are the facets not queryable if i use
Your DevartEfGenerator for the model?
*.edml :?: :?:

entities = new DevartDemo.DevartEntities();
depts = entities.Depts.ToList();
int? dmaxLength = GetMaxLength(new Dept(), "Dname", entities.Depts);
returns 0

EntityModelCodeGenerator on the same table works and i get the facets.
*.edmx


EntitiesTestModel mentities = new EntitiesTestModel();
List deptsm = mentities.DEPT.ToList();
int? mmaxLength = GetMaxLength(new DEPT(), "DNAME", mentities.DEPT);

returns 14 8) 8)



This I have found in the internet! 8) 8) 8)

private int?
GetMaxLength(EntityObject entite, string nomPropriete, ObjectQuery query)
{
int? result = null;
using (var contexte = query.Context)
{
var q = from meta in contexte.MetadataWorkspace.GetItems(DataSpace.CSpace).Where(
m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType)
from p in (meta as EntityType).Properties.Where(
p => p.DeclaringType.Name == entite.GetType().Name
&& p.Name == nomPropriete && p.TypeUsage.EdmType.Name == "String")
select p;
var queryResult = from meta in contexte.MetadataWorkspace.GetItems(DataSpace.CSpace).Where(
m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType)
from p in (meta as EntityType).Properties.Where(
p => p.DeclaringType.Name == entite.GetType().Name
&& p.Name == nomPropriete && p.TypeUsage.EdmType.Name == "String")
select p.TypeUsage.Facets["MaxLength"].Value;

if (queryResult.Count() > 0)
{
result = Convert.ToInt32(queryResult.First());
}
}
return result;
}


Missed I something, or must I write a query to the database to get the facets.

Thanks

Roman

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 12 Aug 2009 08:09

The current 5.25.39 build of dotConnect for Oracle already returns the MaxLength facet value for the Devart Entity model.
We are working on the implementation of the support for other facets.

HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

Post by HCRoman » Wed 12 Aug 2009 08:48

:lol: :lol: :lol: :lol:

I downloaded one day befor this build....

Now it works, great, after I updated the model.

When do you think the other facets are supported??

precision, scale are the most wanted

Tnx Roman

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 12 Aug 2009 09:54

I will let you know as soon as timeframe is available.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 03 Sep 2009 07:06

Precision and Scale facets are implemented in the upcoming build.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 17 Sep 2009 11:59

Please note that the MaxLength facet is serialized only for the String and Binary properties.
The Precision and Scale facets are serialized for Decimal prperties only.

pcrissman
Posts: 8
Joined: Mon 28 Sep 2009 13:16

Precision and Scale only avail for Decimal

Post by pcrissman » Thu 29 Oct 2009 17:07

Hi,
Is there a reason the precision and scale are only available for Decimal?
We have fields in Oracle defined as NUMBER(9,2) and NUMBER(9,3).. and would have loved to query the metadata for precision and scale to do some formatting?

Pam Crissman

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 02 Nov 2009 10:59

We will investigate the possibility to add support for these facets for Double.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 05 Nov 2009 13:22

Entity Framework validates the content of the EDMX file. It is forbidden to set the Precision and Scale facets for the Double columns of conceptual model entities. In this case there will be errors like "Precision facet isn't allowed for properties of type Double.". That's why we will not support this functionality.

HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

This is ok for doubles, but i would like to force decimals

Post by HCRoman » Thu 05 Nov 2009 13:32

Hi Shalex,

this is ok and I do not need support for precision and scale for double.

But how can I force the generator to use decimals instead of double for all number with any scale > 0.

Only if double does not fit, the generator switches to decimal and this is the problem!!!

The refactoring settings should have a flag to force decimals instead of double and than correctly import precision and scale.

We have changed our model to decimals and it is a horror to merge after reimport.....

Roman

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 05 Nov 2009 15:22

Roman, my previous answer about Double was addressed to Pam Crissman.

The possibility of mapping types customisation. The crusial issue in this point: there will be not enough to have one flag in refactoring settings, because different model modifications are required for different users. So we think that this is a wrong way. One of possible solutions is an implementation of possibility for Entity Developer to execute the C# scripts which can modify an existing model loaded to Entity Developer. In this case we provide several simple examples of such scripts in our documentation.

HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

double/decimal

Post by HCRoman » Fri 06 Nov 2009 10:25

Hi Shalex,

is this now a feature or only in the future available?

I think, it should be possibly coded in the templates....??

Roman

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 06 Nov 2009 14:13

Changing the model in the most cases will cause different errors in the frame of existing templates. We consider the possibility of implementing the C# scripts execution, that can modify a model without any problems. We plan to implement this functionality in the next version of Entity Developer.

HCRoman
Posts: 55
Joined: Wed 12 Aug 2009 05:47

double/decimal

Post by HCRoman » Fri 06 Nov 2009 14:23

:) :) :)

Ok, still waiting and merging....

Roman

Post Reply