locked
how to match words with sqlite in universal apps (with regex?)

    Question

  • Since universal apps are unable to target System.Data, I cannot use the SQLiteFunction class that is part of ADO to make my own Regex class. I have never made a wrapper or targeted another language, so I don't understand what's going on when I look a c# samples targeting c code base.

    Michael DiLeo

    Saturday, October 4, 2014 11:24 PM

Answers

  • Hi Michael,

    Indeed, ADO is not available in Windows Store App, but you could ref to this documentation: SQLite, here explain in detail how to work with CRUD for SQLite.

    To make a regex function, I think Linq could be your friend: How to: Combine LINQ Queries with Regular Expressions, here the documentation show you how to use the Regex class to create a regular expression for more complex matching in text strings. The LINQ query makes it easy to filter on exactly the files that you want to search with the regular expression, and to shape the results, it could be apply to your scenario.

    Also Regex Class is avaialable for Windows Store App.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, October 6, 2014 2:42 AM
    Moderator
  • Thanks for the note. I'll look into maybe using linq, if I can. I'm also looking into perhaps making a wrapper function to relpace the ADO.NET version.

    I'm using text as my sql command so run this query:

    select
    	ID,
    	Text as English,
    	group_concat(Japanese) as Japanese,
    	Character
    from
    (
    	select 
    		r.ID,
    		r.Text,
    		ch.Text as Character,
    		reading.Text as Japanese
    	from
    	(
    		(
    		select
    			r.ID,
    			r.Text,
    			rl.Language,
    			r.ChID,
    			rl.ID
    		from Reading r
    		join ReadingLanguage rl on r.RLID = rl.ID
    		where r.RLID = 1
    		and r.Text like '%food%'
    		)r
    	join Reading reading on reading.RLID in (8,9) 
    	join ReadingLanguage rl on reading.RLID = rl.ID 
    	join Character ch on r.ChID = ch.ID 
    	and reading.ChID = r.ChID
    	)
    	order by rl.ID desc
    ) 
    group by Character;




    Michael DiLeo

    Monday, October 6, 2014 3:48 AM

All replies

  • Hi Michael,

    Indeed, ADO is not available in Windows Store App, but you could ref to this documentation: SQLite, here explain in detail how to work with CRUD for SQLite.

    To make a regex function, I think Linq could be your friend: How to: Combine LINQ Queries with Regular Expressions, here the documentation show you how to use the Regex class to create a regular expression for more complex matching in text strings. The LINQ query makes it easy to filter on exactly the files that you want to search with the regular expression, and to shape the results, it could be apply to your scenario.

    Also Regex Class is avaialable for Windows Store App.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, October 6, 2014 2:42 AM
    Moderator
  • Thanks for the note. I'll look into maybe using linq, if I can. I'm also looking into perhaps making a wrapper function to relpace the ADO.NET version.

    I'm using text as my sql command so run this query:

    select
    	ID,
    	Text as English,
    	group_concat(Japanese) as Japanese,
    	Character
    from
    (
    	select 
    		r.ID,
    		r.Text,
    		ch.Text as Character,
    		reading.Text as Japanese
    	from
    	(
    		(
    		select
    			r.ID,
    			r.Text,
    			rl.Language,
    			r.ChID,
    			rl.ID
    		from Reading r
    		join ReadingLanguage rl on r.RLID = rl.ID
    		where r.RLID = 1
    		and r.Text like '%food%'
    		)r
    	join Reading reading on reading.RLID in (8,9) 
    	join ReadingLanguage rl on reading.RLID = rl.ID 
    	join Character ch on r.ChID = ch.ID 
    	and reading.ChID = r.ChID
    	)
    	order by rl.ID desc
    ) 
    group by Character;




    Michael DiLeo

    Monday, October 6, 2014 3:48 AM
  • That is also a possible solution! Let the SQLite Engine handle the query should as same as Linq.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, October 7, 2014 1:23 AM
    Moderator