This project is read-only.

What if UniqueAttribute is not the identity one?

Jul 14, 2009 at 7:22 PM

I get stuck on my current project because when I define the object I marked the primarykeys fields on database as UniqueAttribute on the object model context item, everything was cool but when I try to add new object or even remove it, the linqextender says that it already has an item with this ID inside... I get a little more inside the code and I saw that the update clause gets the items marked as UniqueAttribute to make the where clause after It insert it, so I would like to know how to handle this, because I need to mark my fields as UniqueAttribute but I dont need that LinqExtender ignores them at Insert or Delete time. I know that I could implement my own attribute for making that possible but this is my last resource because I dont really want to have a custom linqextender because I will have that on mind if a new version comes out, Any Ideas???

Thanks In Advance

KMILO

Jul 15, 2009 at 7:55 AM
Edited Jul 15, 2009 at 8:01 AM

You can use the Extender.Settings to mark a property as unique rather specifying it to the object itself.

http://weblogs.asp.net/mehfuzh/archive/2009/06/06/extending-your-existing-api-or-legacy-data-classes-to-support-linq.aspx

Actually, i will add a new option , do not ignore that will solve your issue. optionally, you can do that in AddItem or UpdateItem for when you are generating the SQL statement by yourself not using the TSQLFormatProvider.

Let me know how it goes. 

Jul 15, 2009 at 4:20 PM

Thank you for your sooner answer Mehfuzh.

I was reading the article that you describe me before I post, I think that I was not too specifical at the last post, Im currently implementing a vsaddin for emulating the behavior of linqtosql, but my entities are objects generated upon some queries on database, for example: I have a table that holds all the object information, another to get the attributes of this object and the last one with the relations of this attributes with the object itself and another objects like itself, so my addin shows graphically this objects and using CodeDOM I will build a dbml diagram with all the custom logic inside to get this objects works as linq, in this part is where your extender comes up, so my objects are dinamically generated using the database properties like nullable and primarykey, in the case of being primary keys my codedom marks this field as uniqueattribute, but getting into your code I could see that your mark as IsNewlyAdded the item when you submit the changes on the objectcontext based on the condition if the item has uniqueattributes, but if mark some attributes as unique, the extender assume that these fields are Identity and are not part of the insert operation, I see several things to do, but all of them implies modifying the core of the extender, and as I say on the first post I dont wanna do that because any time you drop a new version I will have to check if the new version impacts my modifying one, if you want for being more clear about my position, I will send the code to you if you want to see it by yourself.

Thanks in Advance

KMILO

Jul 15, 2009 at 6:22 PM

How about i add you in the project, so that you can contribute and modify things as well of course.

Jul 15, 2009 at 8:28 PM

Sounds very cool man, Im a little busy right now and my english is not the best as you can see, but Ill be so thankfully if you add me to your project and I hope I can help you and the community on this.

Cheers

KMILO

Jul 16, 2009 at 4:34 PM
Edited Jul 16, 2009 at 4:36 PM

Ok, Im start the modifications to the extender I implement a new attribute marked as IsIdenity for making a difference on Unique and Identity fields on database, this works perfectly at inserting time on the datacontext, but when I modify some entities the bucket still recognize the IsNewlyAdded because the method to get this property value its getting all the unique and identity attributes on item, and if its new or modified always will have this atributtes set, how can I difference better when Im inserting or updating?

Thanks In Advance

KMILO

Jul 16, 2009 at 9:05 PM

That's cool but original idea was to remove the dependency from any database related attrubutes as extender can be used in other projects like LinqToFlickr. May be you can do a TSqlFormater modification.. any let me know how it goes.. i will be adding you to the project as well. Is this your original codeplex id?

Jul 16, 2009 at 9:08 PM

Yeap It is, Im going to fill up my profile for being a little more verbosity at my expertises :D

Cheers

KMILO

Jul 24, 2009 at 6:05 PM

Hi again Mezfuzh,

I recently finished my own implementation of LINQEXTENDER, and has some new features that I would like to you to check, please tell me where I can send you an email with the code, Im currently correcting some troubles with the predicates at the objects collections, do you know if your version has this issues too? the issues are expecifically that I provide the predicate and the collection cannot make the query on itself and returns me the entire collection, any ideas?

TIA,

KMILO

Jul 24, 2009 at 9:09 PM

Hey,

Let me know the features.. I will take a look.. optionally.. I will set you up an account, which i forgot to do earlier. But please list down the features you have made, also add few test methods regarding it.

Regards,

Mehfuz.

From: kmilovm [mailto:notifications@codeplex.com]
Sent: Friday, July 24, 2009 8:06 PM
To: mehfuz@gmail.com
Subject: Re: What if UniqueAttribute is not the identity one? [LinqExtender:62399]

From: kmilovm

Hi again Mezfuzh,

I recently finished my own implementation of LINQEXTENDER, and has some new features that I would like to you to check, please tell me where I can send you an email with the code, Im currently correcting some troubles with the predicates at the objects collections, do you know if your version has this issues too? the issues are expecifically that I provide the predicate and the collection cannot make the query on itself and returns me the entire collection, any ideas?

TIA,

KMILO

Read the full discussion online.

To add a post to this discussion, reply to this email (LinqExtender@discussions.codeplex.com)

To start a new discussion for this project, email LinqExtender@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Jul 24, 2009 at 9:47 PM

Hi Mehfuzh,

First than all I want to apologize for my mispelling of your name at last post, sorry for that!!! well about the modifications that I made were in the bucket attempting to work with Ignore attributes at all time but the sql process, in fact you could make several operations at bucket time with this fields at your own implementation of the provider and another objetcs but it will ignore them at CRUD time, another feature is the Identity attribute, marking a property with this attribute you will gain some database like functionality where the unique field is different than identity one. 

Im still having issues with the predicates, can you give me a little help on that? Thanks in advance.

KMILO

Jul 25, 2009 at 7:21 AM

Hi,

Now, the issue is Identity makes the attribute more database centric, remember LinqExtender is a generic product not a database tool , but yes , it is mostly used in database. Actually, I should remove the TSql stuff from LinqExtender.Core to LinqExtender.Providers , then we can modify the TSqlFormat provider the way we want.

You could have added just a property in unique attribute that will make it , non identity. Like IsAutoGenerated = true, then you can specify it either from attribute or Extender.Settings. Let me know what is the issue with predicate, I mean few codes.

My email : mehfuz@gmail.com

Regards,

Mehfuz.

From: kmilovm [mailto:notifications@codeplex.com]
Sent: Friday, July 24, 2009 11:47 PM
To: mehfuz@gmail.com
Subject: Re: What if UniqueAttribute is not the identity one? [LinqExtender:62399]

From: kmilovm

Hi Mehfuzh,

First than all I want to apologize for my mispelling of your name at last post, sorry for that!!! well about the modifications that I made were in the bucket attempting to work with Ignore attributes at all time but the sql process, in fact you could make several operations at bucket time with this fields at your own implementation of the provider and another objetcs but it will ignore them at CRUD time, another feature is the Identity attribute, marking a property with this attribute you will gain some database like functionality where the unique field is different than identity one.

Im still having issues with the predicates, can you give me a little help on that? Thanks in advance.

KMILO

Read the full discussion online.

To add a post to this discussion, reply to this email (LinqExtender@discussions.codeplex.com)

To start a new discussion for this project, email LinqExtender@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Jul 30, 2009 at 8:25 PM

Hi mehfuzh,  I already sent to you the code, and the explanation of my predicate issues, that Im still having, I can get single results but when the results throws several records does not work. thanks for any tip that you can give me on this.

TIA,

KMILO

 

Jul 31, 2009 at 9:09 AM
In the your code there is one file missing its says.. please check my
last comment.


On Thu, Jul 30, 2009 at 10:25 PM, kmilovm<notifications@codeplex.com> wrote:
> From: kmilovm
>
> Hi mehfuzh,  I already sent to you the code, and the explanation of my
> predicate issues, that Im still having, I can get single results but when
> the results throws several records does not work. thanks for any tip that
> you can give me on this.
>
> TIA,
>
> KMILO
>
>
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com



--
Best Regards,
Mehfuz Hossain
http://weblogs.asp.net/mehfuzh
Aug 5, 2009 at 9:01 AM

Hi,

I have added you as a contributor to the project with this  kmilovm username. If you get , latest bits, you will see that I have separated the SQL formatter from the main project as it should not be tied to the main project.

Now, the idea is that we can be able to add any attributes to the settings using the Fluent settings, that will make it as a generic project.

Like

Extender.Settings.For(book=> book.id).WithAttribute(typeof(MyAttribte)).MarkAsUnique(false);  that will make it unique but non identity.

Similarly,

Extender.Settings.For(book=> book.id). MarkAsUnique(false);  that will make it unique but non identity.

Also, I have a plan to generate meta language like (OQL) instead of original sql from the formatter that will make it portable to different databases. That’s it for now, let me know, if you can help me on that.

Regards,

Mehfuz

 

From: kmilovm [mailto:notifications@codeplex.com]
Sent: Friday, July 31, 2009 2:25 AM
To: mehfuz@gmail.com
Subject: Re: What if UniqueAttribute is not the identity one? [LinqExtender:62399]

From: kmilovm

Hi mehfuzh, I already sent to you the code, and the explanation of my predicate issues, that Im still having, I can get single results but when the results throws several records does not work. thanks for any tip that you can give me on this.

TIA,

KMILO

Read the full discussion online.

To add a post to this discussion, reply to this email (LinqExtender@discussions.codeplex.com)

To start a new discussion for this project, email LinqExtender@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Aug 23, 2009 at 5:49 PM

Hi Again Mehfuz

 

Sorry for being a little away of the project but I was attending some work issues different to this, so I found the cause of my predication issues, the reason is located on IQuery interfaces, it only implements any and count methods, but not the where that I need, please tell me if I need to expand this Interface to achieve this or you have a better idea on that, fixing this, I will have the time needed to be dedicated to help you achieving your new goal, if you still need my help off course, just let me know the details of your new idea if you have them, and I will separate some hours at my weekend to working on it by now, when I resolve my predicate issue I can give more time to work on it. 

Thank you in advance. 

KMILO

Aug 23, 2009 at 6:33 PM

First of all can you give me another username of yours at codeplex, unfortunate whenever I try to add in the contributor list I get an exception, don’t know why ?  You can feel free to make changes that solve problem globally.

From: kmilovm [mailto:notifications@codeplex.com]
Sent: Sunday, August 23, 2009 11:50 PM
To: mehfuz@gmail.com
Subject: Re: What if UniqueAttribute is not the identity one? [LinqExtender:62399]

From: kmilovm

Hi Again Mehfuz

Sorry for being a little away of the project but I was attending some work issues different to this, so I found the cause of my predication issues, the reason is located on IQuery interfaces, it only implements any and count methods, but not the where that I need, please tell me if I need to expand this Interface to achieve this or you have a better idea on that, fixing this, I will have the time needed to be dedicated to help you achieving your new goal, if you still need my help off course, just let me know the details of your new idea if you have them, and I will separate some hours at my weekend to working on it by now, when I resolve my predicate issue I can give more time to work on it.

Thank you in advance.

KMILO

Read the full discussion online.

To add a post to this discussion, reply to this email (LinqExtender@discussions.codeplex.com)

To start a new discussion for this project, email LinqExtender@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com