Sql Custom , FillData


Author
Message
Tony Charpentier
Tony Charpentier
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: StrataFrame Users
Posts: 10, Visits: 81
Hello

When i write in my bo a Sql for statistics.

Like this :

select TOP 10 COUNT (*) as NBACQ, uti_signature from Clients where cli_id>10
group by uti_id

I use only 2 fields , and strataframe ask me to put all field in the query.

Like this :

Le cast spécifié n'est pas valide.

Description : Une exception non gérée s'est produite au moment de l'exécution de la requête Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.

Détails de l'exception: System.InvalidCastException: Le cast spécifié n'est pas valide.

Erreur source:

Ligne 899 :        public System.DateTime cli_dtcour {Ligne 900 :            get {Ligne 901 :                return (System.DateTime)this.CurrentRow["cli_dtcour"];Ligne 902 :            }Ligne 903 :            set {


It's possible to put a sql custom , with few fields in Business Object.
With ado.net it's possible, or if i wrote a view with few fields it's works so.

But in my statistics , i have too much view, it's why i want to create my own query.

All Bo's field get a non null value .

thanks for your help
StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
We do this 2 ways, Tony:

1) When we retrieve only 2 columns into a business object that has 5 fields, we make note of it and ensure that we don't try to access the properties for the other 3 fields, or we will get an exception.  There are several places where we only want to pull back the first and last name of a person, and not their address, phone numbers, photo, etc., so we only get the fields we need and only access the properties for the fields we retrieved.

2) We build a business object from a "fake" table specified in the DDT.  We have a DDT project called Pseudo Tables, that contains metadata for tables that never get deployed.  The metadata is only used to create business objects.  When we have a complex query that retrieves a fancy join of 25 tables, we create the structure of the output of that query as a fake table in that project, and then build the business object on that.  

In neither of these scenarios do we ever save data back to the database, so if you're looking to retrieve only a few fields and then update the record, you will need to turn off updates/inserts by stored procedures and dynamically add all of the fields that you excluded to the FieldsToExcludeFromInsert or the FieldsToExcludeFromUpdate properties.

Also, you mentioned that all the fields in the BO receive a non-null value.  You can change that by setting AllowNullValuesOnNewRow to True.  It defaults to False, and initializes all of the fields to non-null when you call NewRow().
StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Also, if you have a null value in a field, you can customize the BOMapper to return an alternate value on DBNull.Value so you don't get the "specified cast is invalid" exceptions.
Michel Levy
Michel Levy
StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)StrataFrame User (319 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
Hi Tony (or Olivier)

you have a datetime Field in your BO - the cli_dtcour - that is not filled by your Quercy, OK? so, the property on the BO is valued to NULL, if you did'nt give any substitution value in the BO mapper. And .net is unable to cast NULLs...

you only need to set an alternate value for NULL

--

Bonjour Tony (ou Olivier)

Tu as un champ datetime dans ton BO - cli_dtcou - qui n'est pas renseigné par ta requète. De ce fait, la propriété du BO est valuée à,NULL si tu ne définis pas de valeur de substitution dans le BO mapper. Et le probème vient de .net, qui ne sait pas faire de cast sur un NULL.

Il te suffit juste de définir une valeur alternative pour ls NULL
Olivier
Olivier
StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)StrataFrame User (196 reputation)
Group: StrataFrame Users
Posts: 96, Visits: 805
Hello all,

Thanks for your help ,

It's possible to add new feature, if we don't use a field into a select and the field don't accept the null,
the Bo don't accept if the new property : ExcludeFieldNotInTheSelect  = true;

Big thanks
Olivier

==============================================
Asp.net C# - Strataframe - telerik
==============================================
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search