Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Nullable types in views vs. tables
 

Pages: 1
Bugs & Issues
Nullable types in views vs. tables
Page:1/1 

  Print all messages in this thread  
Poster Message
magic
User



Location:
Waterloo, ON, Canada
Joined on:
24-Nov-2008 19:57:35
Posted:
125 posts
# Posted on: 17-Nov-2009 20:38:57.  
I just ran into trouble because I was using the .IsNullable property on a field that is coming from a view, but it is imported into the project as an entity (based on a typed view).

I did some reading about this topic here:
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=16282

The problem is though that if I develop logic that is based on an EntityField2 (and no knowledge - at least for now) from "where this field comes" (a table or a view) since the entity can be based on both, how do I know whether I can trust the .IsNullable property?

Is v3.0 supposed to handle this stuff differently?
LGP v2.6 Final (May 12th, 2009 / v05122009; Adapter), Web Application (.Net 2.0, SqlServer 2005)  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
34655 posts
# Posted on: 17-Nov-2009 21:53:46.  
the problem is sqlserver, (and other db's as well, though sqlserver mainly) which doesn't update meta-data of a view when the tables in the view change.

In v3 we indeed obtain the meta-data as-is from the db and with nullability. Does that help? no. the thing is that if a field in a table is changed to be nullable, the view(s) the field is in won't be updated, at least not in the sqlserver meta-data.



Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
magic
User



Location:
Waterloo, ON, Canada
Joined on:
24-Nov-2008 19:57:35
Posted:
125 posts
# Posted on: 17-Nov-2009 22:24:35.  
I know that SQLServer is trouble! Wink Nevertheless some people are not asked and have to work with it. Angry

What I'm trying to understand is how (or whether) I can use the .IsNullable property at all.

Since I don't know whether it is "coming from" a view or a table, how do I know whether I can trust it or not? Remember that I use LGP entities based on typed views too.

Also, why does LGP set the .IsNullable property to false for all columns of an entity based on a view? Why not "just" say it is unknown = null?
LGP v2.6 Final (May 12th, 2009 / v05122009; Adapter), Web Application (.Net 2.0, SqlServer 2005)  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
7618 posts
# Posted on: 18-Nov-2009 06:02:55.  
magic wrote:
I know that SQLServer is trouble! Wink Nevertheless some people are not asked and have to work with it. Angry

That's the way it is unfortunately

magic wrote:
What I'm trying to understand is how (or whether) I can use the .IsNullable property at all.

Since I don't know whether it is "coming from" a view or a table, how do I know whether I can trust it or not? Remember that I use LGP entities based on typed views too.

So, in short, you want to know whether an "entity" is based on a "table" or on a "view" to know if you can trust in IsNullable property. Well, AFAIK you can't. However you could add a custom property to each "entity based on a view" to flag it, then you could access that property (using the CustomPropertiesOfType entity's property) and know if you can trust on it.

magic wrote:
Also, why does LGP set the .IsNullable property to false for all columns of an entity based on a view? Why not "just" say it is unknown = null?

SqlServer doesn't update the nullability state of a view field when the nullability of a table field changes (which is in a view). This thus leads to errors, hence that piece of retrieval code is commented out the code in the driver. More info: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=14825


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
magic
User



Location:
Waterloo, ON, Canada
Joined on:
24-Nov-2008 19:57:35
Posted:
125 posts
# Posted on: 30-Dec-2009 05:26:41.  
First of all (as I already stated a couple of times), I understand that MsSQL sucks and there's not much one can do about it. Wink

But ... why is LGP converting nullable types into not nullable? I have a view that has a nullable boolean field. The value of this field in a particular row is NULL, but when I try to access the value through the LGP entity, it is FALSE. This totally falsifies my data! Shocked LGP does the same for numeric values (turns them to 0), but not with strings where the value stays NULL.

If no assumptions can be made about whether a field is nullable or not, it should be nullable and not assigned a value that isn't there?

Furthermore, I have tried to read through the thread that you suggested, and I don't think I can follow. Confused Can you please elaborate more on the idea of changing the source code in SqlServerSchemaRetriever.cs, line 1263? How am I supposed to do that?
LGP v2.6 Final (May 12th, 2009 / v05122009; Adapter), Web Application (.Net 2.0, SqlServer 2005)  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
13698 posts
# Posted on: 30-Dec-2009 09:32:14.  
This will be handled in v.3.0

Quote:
Can you please elaborate more on the idea of changing the source code in SqlServerSchemaRetriever.cs, line 1263? How am I supposed to do that?

You should get the Drivers source code, found in the SDK package. (Download it from the website).


  Top
magic
User



Location:
Waterloo, ON, Canada
Joined on:
24-Nov-2008 19:57:35
Posted:
125 posts
# Posted on: 30-Dec-2009 13:11:41.  
I think I'm really too stupid to find the download. Sorry.

Can you please provide a link or instructions? Thank you.
LGP v2.6 Final (May 12th, 2009 / v05122009; Adapter), Web Application (.Net 2.0, SqlServer 2005)  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
34655 posts
# Posted on: 30-Dec-2009 13:39:02.  
magic wrote:
I think I'm really too stupid to find the download. Sorry.

Can you please provide a link or instructions? Thank you.

customer area -> v2.6 (left side) -> Extras -> LLBLGen Pro SDK Regular Smiley


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.